Three tiny git aliases that make git worktrees easy to use — no more remembering the full git worktree add/list/remove syntax.
Worktrees are created in a .worktrees/ folder at the root of your repository, and the folder is automatically added to .gitignore. The aliases live in your global git config, so they work in every repo, on Windows, macOS, and Linux, and in any shell (bash, zsh, PowerShell, cmd) — Git ships its own sh on Windows, so the same config runs everywhere.
| Command | What it does |
|---|---|
git wt |
List all worktrees. Ensures .worktrees/ is in .gitignore. |
git wtn <branch> |
Create a new branch and a worktree for it at <repo-root>/.worktrees/<branch>, then print the path. |
git wtr <branch> |
Remove the worktree at <repo-root>/.worktrees/<branch>, then print the path. |
$ git wtn feature-login
Preparing worktree (new branch 'feature-login')
Created worktree for branch feature-login at /path/to/repo/.worktrees/feature-login
$ git wt
/path/to/repo a1b2c3d [main]
/path/to/repo/.worktrees/feature-login e4f5g6h [feature-login]
$ git wtr feature-login
Removed worktree for branch feature-login at /path/to/repo/.worktrees/feature-loginBranch names with slashes (e.g.
feature/login) create nested folders under.worktrees/— that works, just pass the same name togit wtr.
Paste this prompt into an AI coding agent (GitHub Copilot CLI, Claude Code, Cursor, etc.):
Install the git worktree aliases from https://github.com/dryotta/git-worktree-helper.
Read that repo's README and run the three `git config --global` install commands from
the "Manual install" section as-is (they are shell-agnostic). Then verify the install
by running: git config --get-regexp "^alias\.wt"
Run these three commands. They are wrapped in single quotes so they work identically in bash, zsh, and PowerShell — copy and paste them as-is.
git config --global alias.wt '!f() { root=$(git rev-parse --show-toplevel); grep -qxF .worktrees/ "$root/.gitignore" 2>/dev/null || echo .worktrees/ >> "$root/.gitignore"; git worktree list; }; f'
git config --global alias.wtn '!f() { root=$(git rev-parse --show-toplevel); grep -qxF .worktrees/ "$root/.gitignore" 2>/dev/null || echo .worktrees/ >> "$root/.gitignore"; path="$root/.worktrees/$1"; git worktree add -b "$1" "$path" && echo "Created worktree for branch $1 at $path"; }; f'
git config --global alias.wtr '!f() { root=$(git rev-parse --show-toplevel); path="$root/.worktrees/$1"; git worktree remove "$path" && echo "Removed worktree for branch $1 at $path"; }; f'Verify:
git config --get-regexp "^alias\.wt"Copy the [alias] block from aliases.gitconfig into your global git config file (~/.gitconfig).
git wt # list all worktrees
git wtn my-feature # new branch + worktree at ./.worktrees/my-feature
git wtr my-feature # remove that worktreegit config --global --unset alias.wt
git config --global --unset alias.wtn
git config --global --unset alias.wtr- Aliases beginning with
!run as shell commands. Thef() { ... }; fwrapper defines a one-shot function so the alias can take positional arguments ($1). git rev-parse --show-toplevelfinds the repository root, so the commands work from any subdirectory.- The
.gitignoreguard usesgrep -qxF(quiet, whole-line, fixed-string) and only appends.worktrees/when it is missing — it never adds a duplicate. - Status messages use
&&, so they only print when the underlyinggit worktreecommand succeeds.
- Git 2.5+ (when
git worktreewas introduced; 2.17+ recommended forworktree remove). - On Windows, use Git for Windows (bundles the
sh,grep, andechothese aliases rely on).