gwt.mp4
gwt is a simple command-line tool to help you manage your Git worktrees with ease. It simplifies the process of creating, navigating, and removing worktrees.
You can read more about git worktree here: https://dev.to/konstantin/checking-out-multiple-branches-at-the-same-time-in-git-and-moving-files-between-them-31hk
- Interactive Navigation: Quickly jump between worktrees using an fzf-powered menu.
- Quick Add: Create a new worktree from an existing branch and switch to it in one command. If the branch doesn't exist, it will offer to create it.
- Easy Removal: Interactively select and remove worktrees.
- Direct Access: Jump directly to a worktree for a specific branch.
- Main Branch Shortcut: Instantly navigate to the worktree of your repository's default branch (main or master).
- Zsh Completion: Tab completion for commands and branch names in Zsh.
You will need to install fzf (see these installation instructions) for the interactive features.
Run this to download gwt and add it to your shell configuration:
curl -sLo ~/.gwt.sh https://raw.githubusercontent.com/gko/gwt/master/gwt.sh
echo 'source ~/.gwt.sh' >> ~/.zshrc # or ~/.bashrcFor Zsh users, you can also install the completion script:
mkdir -p ~/.zsh/completions
curl -sLo ~/.zsh/completions/_gwt https://raw.githubusercontent.com/gko/gwt/master/_gwt.zsh_completionWith zinit
In your .zshrc:
zinit light gko/gwtWith antigen
In your .zshrc:
antigen bundle gko/gwt- Clone this repository or download the gwt.sh script.
git clone https://github.com/gko/gwt.git- Source the gwt.sh script in your shell's configuration file (e.g.,
~/.bashrc,~/.zshrc). Add the following line:
# Make sure to use the correct path to where you cloned the repo
source /path/to/gwt/gwt.sh- Restart your shell or source the configuration file for the changes to take effect:
source ~/.zshrc or
source ~/.bashrcFor Zsh users, gwt comes with a completion script for commands and branch names.
- Make sure the
_gwt.zsh_completionfile is in a directory that is part of your Zshfpath. You can check yourfpathwith echo$fpath. A common location is a custom completions directory like~/.zsh/completions. - If you don't have a custom completions directory, you can create one and add it to your
~/.zshrc:
mkdir -p ~/.zsh/completions
# Add this to your .zshrc, before the line that sources oh-my-zsh if you use it
fpath=($HOME/.zsh/completions $fpath)- Copy or symlink the
_gwt.zsh_completionfile into that directory.
# Rename it to '_gwt' so Zsh can find it
cp /path/to/gwt/_gwt.zsh_completion ~/.zsh/completions/_gwt- Restart your shell. You should now have tab completion for gwt commands.
Usage: gwt [command]
Example:
gwt interactively choose a worktree and cd into it
gwt add <branch> create a new worktree for <branch> and cd into it
gwt main jump to default branch worktree (or repo root)
gwt master alias of 'gwt main'
gwt <branch> jump to the worktree for <branch>
gwt remove [-f|--force]
interactively remove a worktree (force removal with -f)
Options:
-h, --help show this help
This project is open source and available under the GPLv3 license.