Skip to content

v2.1.0

Choose a tag to compare

@github-actions github-actions released this 28 Jul 18:11
· 6 commits to main since this release
Immutable release. Only release title and notes can be modified.
76f2bc0

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, and GIT_WT_BARE_ROOT environment variables.
  • Repeated git config --add values 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=1 echoes 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 switch is intercepted: git wt add keeps printing the created worktree path to stdout, so scripts, hooks, and the Claude Code WorktreeCreate integration keep working unchanged.
  • A thin git() wrapper makes the git wt switch spelling work too; use --no-git-wrapper if another tool already wraps git.
  • 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-wt

Using Nix Flakes

nix run github:ahmedelgabri/git-wt

Manual 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