wt
A CLI I built to manage git worktrees. It lets me spin up isolated copies of my repo so I can context-switch without stashing, committing, or rebuilding anything.
Why I built this
One of my biggest current pet peeves is that I’ll be in the middle of working on something and then something small comes up, like a five-line hotfix, a quick repro on main, or someone pinging me to check their branch. The actual task takes three minutes. The context-switch around it is brutal:
- Stash or commit my in-progress work
- Check out a new branch
- Rebuild and serve the app
- Do the actual thing (the three-minute part)
- Commit and push
- Switch back to my branch
- Unstash or undo that throwaway commit
- Rebuild and serve again
By the time I’m back to where I started, twenty minutes have gone by and I’ve forgotten what I was doing.
Git worktrees fix this. They let you have multiple checkouts of the same repo at the same time, each on its own branch, each in its own directory. No stashing, no branch-switching, no rebuilding. You just cd somewhere else.
The problem is that the built-in git worktree commands are a little clunky. They don’t handle branch naming, or navigation, or cleanup. So I wrote a tiny wrapper that does.
What it does
wt is a Bash CLI with four commands:
wt create <name>— spins up a new worktree as a sibling directory, auto-prefixes the branch (e.g.areel/fix-auth), and optionally registers it with git-spicewt nav— fuzzy-find and jump into any worktree withfzfwt remove— clean up a worktree, and optionally delete the branch toowt list— see all active worktrees
Worktrees live as siblings to my main repo, so my primary checkout never gets touched. I can have three things going at once and flip between them instantly.
What’s missing
The big thing I still want is a post-create hook. Right now, wt create copies tracked files into the new worktree and stops there. In practice, there’s always more setup.
At work, for example, a fresh worktree means I also need to run docker compose build, reinstall node modules, copy over .env, and change the ports on every container so I don’t collide with my main checkout. All of that could live in a .wt/post-create script that runs after every wt create. That’s the next thing I want to add.