Skip to content

Instantly share code, notes, and snippets.

@bfollington
Last active November 5, 2025 06:19
Show Gist options
  • Save bfollington/dd61c7eaeee729b4c3a1b15dc2bc230c to your computer and use it in GitHub Desktop.
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 ../../.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 ../../.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 worktree remove .worktrees/$branch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment