Repository navigation
v2.1.0
·
6 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
Highlights
Worktree lifecycle hooks
Run shell commands around worktree creation and removal, configured through Git config so they can be scoped per repository or globally (adapted from k1LoW/git-wt, #21 thanks @cwill747):
git config --add wt.beforeadd './scripts/check-worktree.sh'
git config --add wt.afteradd 'cp ../main/compile_commands.json .'
git config --add wt.beforeremove './scripts/cleanup-worktree.sh'
git config --add wt.afterremove 'workspace-registry remove "$GIT_WT_PATH"'- Four events:
wt.beforeadd,wt.afteradd,wt.beforeremove,wt.afterremove— before-hooks can veto the operation by exiting non-zero. - Hooks receive context via
GIT_WT_EVENT,GIT_WT_PATH,GIT_WT_BRANCH, andGIT_WT_BARE_ROOTenvironment variables. - Repeated
git config --addvalues run in order and stop at the first failure; multiline values are supported. - Hook output goes to stderr, so
git wt add's stdout stays machine-readable.DEBUG=1echoes hooks instead of running them.
See the Hooks section in the README for the full lifecycle table and failure semantics.
Shell integration: git wt switch now cds for you
A new init command emits a shell wrapper (the zoxide/direnv pattern) so git wt switch changes directory directly instead of requiring cd "$(git wt switch)" — thanks @milesd (#26):
# bash (~/.bashrc)
eval "$(git-wt init bash)"
# zsh (~/.zshrc)
eval "$(git-wt init zsh)"
# fish (~/.config/fish/config.fish)
git-wt init fish | source- Only
switchis intercepted:git wt addkeeps printing the created worktree path to stdout, so scripts, hooks, and the Claude CodeWorktreeCreateintegration keep working unchanged. - A thin
git()wrapper makes thegit wt switchspelling work too; use--no-git-wrapperif another tool already wrapsgit. - Known limitation: global git flags before the subcommand (e.g.
git -C <path> wt switch) bypass the wrapper and print the path instead.
Changes
- feat: add worktree lifecycle hooks, migrated from https://github.com/k1LoW/git-wt (#21)
- feat(init): add shell integration for automatic directory changing (#26)
- docs: list shell integration and lifecycle hooks in features
- chore: bump version to 2.1.0
Installation
Using Homebrew
brew install ahmedelgabri/tap/git-wtUsing Nix Flakes
nix run github:ahmedelgabri/git-wtManual Download
Download the archive for your platform, extract it, and place the binary in your $PATH:
tar xzf git-wt-2.1.0-<OS>-<ARCH>.tar.gz
cp git-wt-2.1.0-<OS>-<ARCH>/git-wt ~/.local/bin/Completions and man pages are included in the archive under completions/ and man/.
Checksums: See git-wt-2.1.0-checksums.txt