| name | git-worktree-runner |
| description | Manages git worktrees using git-worktree-runner (gtr). Use when the user needs to create, list, remove, or navigate worktrees with `git gtr` commands, open editors or AI tools in worktrees, manage parallel development branches, or check out GitHub PRs (including from forks) into worktrees. |
Git Worktree Runner (gtr)
git-worktree-runner (gtr) is a CLI tool that wraps git worktree with quality-of-life features for modern development workflows including editor and AI tool integration.
Quick Start
git gtr new feature-branch
git gtr new my-branch --from origin/feature-branch
git gtr editor feature-branch
git gtr ai feature-branch
git gtr rm feature-branch
Commands
Creating Worktrees
git gtr new feature-name
git gtr new my-branch --from origin/main
git gtr new hotfix --from v1.2.3
git gtr new feature -e
git gtr new feature -a
git gtr new feature -e -a
Opening Editor / AI Tool
git gtr editor feature-branch
git gtr ai feature-branch
Running Commands
git gtr run feature-branch npm test
git gtr run feature-branch pnpm build
Navigation
cd "$(git gtr go feature-branch)"
Listing and Managing
git gtr list
git gtr rm feature-branch
git gtr mv old-name new-name
Configuration
git gtr config set gtr.editor.default cursor
git gtr config set gtr.ai.default claude
git gtr config add gtr.copy.include "**/.env"
git gtr config add gtr.copy.include "**/.env.local"
git gtr config add gtr.copy.include "**/.env.example"
git gtr config list
Example: Parallel AI Development
git gtr new feature-auth --from origin/main
git gtr new feature-api --from origin/main
git gtr new bugfix-login --from origin/main
git gtr ai feature-auth
git gtr ai feature-api
git gtr ai bugfix-login
git gtr list
git gtr rm feature-auth
git gtr rm feature-api
git gtr rm bugfix-login
Example: PR Review in Isolated Worktree
git gtr new review-pr-123 --from origin/pr-branch
git gtr editor review-pr-123
git gtr run review-pr-123 pnpm test
git gtr rm review-pr-123
Example: Hotfix While Working on Feature
git gtr new hotfix-critical --from origin/main
git gtr new hotfix-critical -e
git gtr rm hotfix-critical
Example: Checkout a Fork PR into Worktree
For PRs from forked repositories, the branch is not on origin. Use GitHub's refs/pull/<number>/head ref to fetch it.
Procedure
Given a PR number or URL:
-
Get PR metadata
gh pr view <PR_NUMBER> --json headRefName,isCrossRepository
-
Check for existing worktree with the same branch name
git worktree list
If it exists, remove it first: git gtr rm <branch>
-
Fetch the PR ref into a local branch (use --force to handle diverged history from force-pushes)
git fetch origin pull/<PR_NUMBER>/head:<BRANCH_NAME> --force
-
Create the worktree with --track local since it's a local-only branch
git gtr new <BRANCH_NAME> --track local
-
Verify
git gtr list
Full example (PR #1223 from a fork)
gh pr view 1223 --json headRefName,isCrossRepository
git fetch origin pull/1223/head:fix/comprehensive-file-formats-docs --force
git gtr new fix/comprehensive-file-formats-docs --track local
git gtr list
Shortening long branch names
git fetch origin pull/1223/head:pr-1223 --force
git gtr new pr-1223 --track local
Common errors
- "refusing to fetch into branch checked out at...": A worktree with that branch exists.
git gtr rm <branch> first.
- "non-fast-forward" rejected: Local branch diverged. Add
--force to the fetch.
- Both errors: Remove the worktree first, then fetch with
--force.