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.
newt [-b] <branch>
newt -d <worktree>
newt -l
<branch>: Create a worktree for the specified branch in.newt/<branch>. Slashes in branch names are converted to hyphens in the directory name.-b: Create a new branch and worktree together.-d <worktree>: 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.
Create a worktree for an existing branch:
newt feature/new-api
# Creates .newt/feature-new-api/ and opens a shell thereCreate a new branch and worktree:
newt -b bugfix/issue-123
# Creates new branch and .newt/bugfix-issue-123/ worktreeList all worktrees with merge status:
newt -l
# Shows worktrees with their branches and merge statusDelete a worktree and its branch:
newt -d feature-new-api
# Removes the worktree and deletes the branch
# Asks for confirmation if the branch hasn't been mergedbrew install cdzombak/oss/newtShell 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:
# 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/_newtInstall my Debian repository if you haven't already:
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 updateThen install newt via apt-get:
sudo apt-get install newtShell completions for bash and zsh are installed automatically.
Pre-built binaries are downloadable from each GitHub Release. Debian packages for each release are available as well.
git clone https://github.com/cdzombak/newt.git
cd newt
make build
cp out/newt-[VERSION]-all $INSTALL_DIR/newtNote: 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:
# Bash (Debian)
source /usr/share/bash-completion/completions/newt
# Zsh (Debian)
# Ensure /usr/share/zsh/vendor-completions is in your $fpath
# and run: compinitShell completion scripts are available in the completions/ directory.
Add to your ~/.bashrc or ~/.bash_profile:
source /path/to/newt/completions/newt.bashOr copy the completion script to your system's bash completions directory:
# macOS (Homebrew)
cp completions/newt.bash $(brew --prefix)/etc/bash_completion.d/newt
# Linux
sudo cp completions/newt.bash /etc/bash_completion.d/newtCopy the completion script to a directory in your $fpath:
# Example: using ~/.zsh/completions
mkdir -p ~/.zsh/completions
cp completions/_newt ~/.zsh/completions/Then add to your ~/.zshrc (before compinit):
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinitOr for Homebrew users:
cp completions/_newt $(brew --prefix)/share/zsh/site-functions/_newt- Issues: github.com/cdzombak/newt/issues
- Author: Chris Dzombak
MIT; see LICENSE in this repository.
