Skip to content

Instantly share code, notes, and snippets.

@bfollington
Last active November 10, 2025 19:34
Show Gist options
  • Select an option

  • Save bfollington/dd61c7eaeee729b4c3a1b15dc2bc230c to your computer and use it in GitHub Desktop.

Select an option

Save bfollington/dd61c7eaeee729b4c3a1b15dc2bc230c to your computer and use it in GitHub Desktop.
Worktree convenience aliases
wt-new() {
branch=$1
git worktree add .worktrees/$branch -b $branch && cd .worktrees/$branch
git config core.hooksPath $(git rev-parse --show-toplevel)/.githooks
}
wt-checkout() {
branch=$1
git worktree add .worktrees/$branch $branch 2>/dev/null || \
git worktree add .worktrees/$branch -b $branch --track origin/$branch
cd .worktrees/$branch
git config core.hooksPath $(git rev-parse --show-toplevel)/.githooks
}
wt-sync() {
git fetch origin && git rebase origin/main
}
wt-remove() {
branch=$1
git worktree remove .worktrees/$branch
}
wt-list() {
git worktree list
}
wt-done() {
branch=$(git branch --show-current)
cd $(git rev-parse --show-toplevel) && git worktree remove .worktrees/$branch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment