worktree is a CLI for people who use Git worktrees as part of their daily development flow and do not want to keep typing the same setup, cleanup, and editor-opening commands over and over.
It wraps the most common worktree tasks into a small workflow-oriented tool:
- create a new worktree from your default base branch
- check out an existing remote branch into its own worktree
- copy local env files into the new worktree
- open the result in your editor automatically
- list, reopen, remove, and clean up worktrees later
This README focuses on the fast path. The documentation website will cover deeper examples, advanced workflows, integrations, and troubleshooting.
Git worktrees are great when you want multiple branches checked out at once, but the raw commands are still a bit awkward for everyday use. In practice, teams usually want a repeatable flow like this:
- branch off
origin/main - create a sibling worktree directory
- copy
.envfiles - open it in the editor
- clean up stale worktrees later
worktree turns that into a few commands with sensible prompts.
By default, worktrees are created in a sibling folder named <repo>.worktrees, so your main repository stays clean while related worktrees stay easy to find.
One of the biggest wins with worktrees is how fast context switching becomes.
Instead of juggling one checkout and constantly doing this dance:
- stash current changes
- switch branches
- do quick fix
- switch back
- unstash and resolve surprises
you keep each task in its own directory and jump between them directly.
That means:
- fewer stash/unstash cycles
- less risk of stash conflicts or forgotten stashes
- less accidental cross-branch contamination
- faster interrupts, reviews, and hotfixes
In short: stop paying a context-switching penalty and stop stashing just to move between tasks.
npm install -g @burglekitt/worktreeOr run it without a global install:
npx @burglekitt/worktree --helpRun the initial configuration once inside a Git repository:
worktree configThe setup flow can configure:
defaultSourceBranchfor new worktrees, such asorigin/maincodeEditorfor automatically opening a worktree, such ascode
Then create your first worktree:
worktree branch feature/improve-readmeThat will:
- create a new branch from your configured source branch
- add a Git worktree under
<repo>.worktrees/feature/improve-readme - copy
.envand.env.localfiles from the main repository - open the new worktree in your configured editor, if one is set
worktree branch feature/add-bulk-actionsCreate from a different source branch:
worktree branch feature/add-bulk-actions --source origin/release/1.4worktree checkout feature/fix-login-timeoutYou can also pass the full remote name:
worktree checkout origin/feature/fix-login-timeoutThis creates a local tracking branch in a dedicated worktree.
worktree listworktree open feature/add-bulk-actionsIf you omit the branch name, the CLI shows an interactive picker.
worktree remove feature/add-bulk-actionsForce removal when you already know what you are doing:
worktree remove feature/add-bulk-actions --forceAliases are also available:
worktree rm feature/add-bulk-actionsworktree cleanupThe cleanup command targets worktrees that are considered safe to remove, for example branches whose remote no longer exists or local worktrees with no tracked remote and no pending work.
| Command | What it does |
|---|---|
worktree config |
Configure defaults like source branch and editor |
worktree branch <name> |
Create a new branch in a new worktree |
worktree checkout <remote-branch> |
Check out an existing remote branch into a worktree |
worktree list |
List known worktrees |
worktree open [branch] |
Open an existing worktree in your editor |
worktree remove [branch] |
Remove one or more worktrees |
worktree cleanup |
Remove stale worktrees that are safe to delete |
For command help at any time:
worktree help
worktree help branchConfiguration is stored in local Git config under the burglekitt.worktree.* namespace.
Examples:
worktree config defaultSourceBranch origin/main
worktree config codeEditor code
worktree config --list
worktree config --missingThe README is intentionally optimized for onboarding and everyday usage.
The documentation website should be the place for:
- in-depth walkthroughs
- team conventions and naming strategies
- integration guides
- edge cases and troubleshooting
- richer examples for different repository layouts
- Git installed and available on your
PATH - Node.js available to run the CLI
- an existing Git repository where you want to manage worktrees
If you want automatic editor launching, make sure your editor command is available in the shell, for example code for Visual Studio Code.
MIT
- Add
configcommand to configure everything needed - Add
branchcommand to create new worktrees - Add
removecommand to delete worktrees - Add
checkoutcommand to create worktree from a remote branch - Add
listcommand to list all worktrees - Add
opencommand to open a worktree in a code editor - Add
cleanupcommand to cleanup stale worktrees - Integrate with JIRA for automated branch naming
- Integrate with ClickUp for automated branch naming
- Integrate with Trello for automated branch naming
