Stop stashing uncommitted changes, wrestling with detached branches, and waiting for npm install.
treeshift turns Git worktrees into a seamless, modern developer experience.
# Run instantly with npx (zero installation required)
npx treeshift| The Everyday Pain 😫 | With treeshift 🚀 |
|---|---|
git stash ➔ git checkout branch ➔ lose .env ➔ wait for rebuild |
treeshift add feat/auth creates an isolated workspace with .env already synced. |
Clunky commands: git worktree add -b feat ../dir origin/main |
One command or interactive prompt: treeshift new feat/auth |
| Forgetting which worktrees are dirty vs clean | Interactive TUI dashboard showing status ([clean], [dirty], time ago). |
| Accumulating dozens of dead worktrees from merged PRs | treeshift clean detects merged branches and safely bulk-prunes them in 1-click. |
Having to manually cd to nested worktree folders |
Shell integration automatically jumps your terminal (cd) when you switch. |
Running treeshift (or ts) with no arguments launches the interactive dashboard:
┌ ▲ treeshift — Git Worktrees Dashboard
│
◇ Select a worktree to switch to, or choose an action:
│
│ ★ main (current) [main] [clean]
│ treeshift · 2h ago "feat(core): initial engine"
│
│ feat/auth-v2 [dirty]
│ treeshift-feat-auth-v2 · 12m ago "fix(auth): session refresh token"
│
│ + Create new worktree
│ 🧹 Clean merged worktrees
│ 🗑️ Remove a worktree
│
└ Switched to: /workspace/projects/treeshift/.worktrees/feat-auth-v2 🚀
npx treeshiftnpm install -g treeshift
# or
bun add -g treeshiftDownload the standalone binary for your OS (treeshift for Linux/macOS, treeshift.exe for Windows) directly from GitHub Releases.
Because subshells cannot change their parent process's directory, treeshift provides a lightweight wrapper so selecting a worktree in the TUI automatically cds into it:
eval "$(treeshift init zsh)"eval "$(treeshift init bash)"treeshift init fish | sourcetreeshift init powershell | Out-String | Invoke-ExpressionPro Tip: Shell integration registers both
treeshift,ts, andwtaliases for maximum speed!
Opens the interactive TUI switcher showing all active worktrees, commit info, and clean/dirty status.
treeshiftSwitch directly to an existing worktree, or prompts to create one if it doesn't exist yet:
treeshift switch feat/billingCreates a new worktree in an isolated directory (.worktrees/<branch>):
- Automatically checks out existing local branch, tracks remote
origin/<branch>, or branches off default base (main). - Auto-syncs
.envfiles (.env,.env.local,.env.development, etc.) safely from the main repository.
# Branch from default (main/master)
treeshift add feat/google-auth
# Branch off a custom base branch
treeshift add fix/safari-bug staging
# Custom path or skip env sync
treeshift add feat/experiment --path ../my-experiment --no-envPrints a clean overview of all active worktrees and their status:
treeshift list
# Or output machine-readable JSON for scripts:
treeshift list --jsonSafely deletes a worktree and prunes Git references:
- Prevents accidental deletion of the main repository.
- Warns if the worktree contains uncommitted or unstaged changes.
- Offers to delete the local Git branch in the same step.
# Interactive selection
treeshift remove
# Direct removal
treeshift remove feat/old-feature --forceScans all worktrees whose branches have already been merged into main (or master), and lets you bulk-delete them in one step:
treeshift cleanYou can customize treeshift per repository by creating a .treeshiftrc.json in your repository root:
{
"location": "internal",
"internalDir": ".worktrees",
"syncEnv": true,
"envFiles": [".env", ".env.local", ".env.development"],
"defaultBaseBranch": "main"
}location:"internal"(inside.worktrees/<branch>) or"sibling"(alongside repo:../<repo>-<branch>).syncEnv: Whether to automatically copy.env*files to new worktrees (default:true).
# Clone the repository
git clone https://github.com/ghazy2001/treeshift.git
cd treeshift
# Install dependencies
bun install
# Run tests
bun test
# Build Node distribution and standalone binary
bun run build
bun run build:binaryContributions, issues, and feature requests are welcome!
Feel free to check issues page.
MIT © Mahmoud Ghazy