https://github.com/cdzombak/newt
Git worktree manager
https://github.com/cdzombak/newt
git worktrees
Last synced: about 6 hours ago
JSON representation
Git worktree manager
- Host: GitHub
- URL: https://github.com/cdzombak/newt
- Owner: cdzombak
- License: mit
- Created: 2025-10-27T17:31:16.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-10-27T19:11:05.000Z (8 months ago)
- Last Synced: 2026-06-29T08:31:13.075Z (7 days ago)
- Topics: git, worktrees
- Language: Shell
- Homepage:
- Size: 693 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# newt
Manage Git worktrees with ease. `newt` is a simple wrapper around Git worktrees that automatically organizes them in a `.newt/` directory, provides merge status tracking, and handles deletion.
## Usage
```text
newt [-b]
newt -d
newt -l
```
### Options
- ``: Create a worktree for the specified branch in `.newt/`. Slashes in branch names are converted to hyphens in the directory name.
- `-b`: Create a new branch and worktree together.
- `-d `: Delete the specified worktree and its branch. Asks for confirmation if the branch has not been merged.
- `-l`: List all worktrees with their merge status (merged/unmerged relative to the default branch).
- `-h`, `--help`: Print help and exit.
- `-v`, `--version`: Print version and exit.
### Examples
Create a worktree for an existing branch:
```shell
newt feature/new-api
# Creates .newt/feature-new-api/ and opens a shell there
```
Create a new branch and worktree:
```shell
newt -b bugfix/issue-123
# Creates new branch and .newt/bugfix-issue-123/ worktree
```
List all worktrees with merge status:
```shell
newt -l
# Shows worktrees with their branches and merge status
```
Delete a worktree and its branch:
```shell
newt -d feature-new-api
# Removes the worktree and deletes the branch
# Asks for confirmation if the branch hasn't been merged
```
## Installation
### macOS via Homebrew
```shell
brew install cdzombak/oss/newt
```
Shell completions for bash and zsh are installed automatically to:
- Bash: `$(brew --prefix)/etc/bash_completion.d/newt`
- Zsh: `$(brew --prefix)/share/zsh/site-functions/_newt`
**Note:** After installation, start a new shell session for completions to take effect. If completions still don't work:
```shell
# For bash, ensure bash-completion is installed and sourced
brew install bash-completion@2
# For zsh, rebuild completion cache
rm -f ~/.zcompdump && compinit
# Verify the completion files exist
ls -la $(brew --prefix)/etc/bash_completion.d/newt
ls -la $(brew --prefix)/share/zsh/site-functions/_newt
```
### Debian via apt repository
Install my Debian repository if you haven't already:
```shell
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://dist.cdzombak.net/deb.key | sudo gpg --dearmor -o /etc/apt/keyrings/dist-cdzombak-net.gpg
sudo chmod 0644 /etc/apt/keyrings/dist-cdzombak-net.gpg
echo -e "deb [signed-by=/etc/apt/keyrings/dist-cdzombak-net.gpg] https://dist.cdzombak.net/deb/oss any oss\n" | sudo tee -a /etc/apt/sources.list.d/dist-cdzombak-net.list > /dev/null
sudo apt-get update
```
Then install `newt` via `apt-get`:
```shell
sudo apt-get install newt
```
Shell completions for bash and zsh are installed automatically.
### Manual installation from build artifacts
Pre-built binaries are downloadable from each [GitHub Release](https://github.com/cdzombak/newt/releases). Debian packages for each release are available as well.
### Build and install locally
```shell
git clone https://github.com/cdzombak/newt.git
cd newt
make build
cp out/newt-[VERSION]-all $INSTALL_DIR/newt
```
### Shell Completions
**Note:** If you installed via Homebrew or the Debian package, shell completions are already installed and configured. The instructions below are only needed for manual installations.
For Homebrew installations, completions should work immediately in new shell sessions. For Debian installations, you may need to restart your shell or source the completion files:
```shell
# Bash (Debian)
source /usr/share/bash-completion/completions/newt
# Zsh (Debian)
# Ensure /usr/share/zsh/vendor-completions is in your $fpath
# and run: compinit
```
#### Manual Installation
Shell completion scripts are available in the `completions/` directory.
##### Bash
Add to your `~/.bashrc` or `~/.bash_profile`:
```shell
source /path/to/newt/completions/newt.bash
```
Or copy the completion script to your system's bash completions directory:
```shell
# macOS (Homebrew)
cp completions/newt.bash $(brew --prefix)/etc/bash_completion.d/newt
# Linux
sudo cp completions/newt.bash /etc/bash_completion.d/newt
```
##### Zsh
Copy the completion script to a directory in your `$fpath`:
```shell
# Example: using ~/.zsh/completions
mkdir -p ~/.zsh/completions
cp completions/_newt ~/.zsh/completions/
```
Then add to your `~/.zshrc` (before `compinit`):
```shell
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit
```
Or for Homebrew users:
```shell
cp completions/_newt $(brew --prefix)/share/zsh/site-functions/_newt
```
## About
- Issues: [github.com/cdzombak/newt/issues](https://github.com/cdzombak/newt/issues)
- Author: [Chris Dzombak](https://www.dzombak.com)
- [GitHub: @cdzombak](https://www.github.com/cdzombak)
## License
MIT; see `LICENSE` in this repository.