devex git cli

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:

  1. Stash or commit my in-progress work
  2. Check out a new branch
  3. Rebuild and serve the app
  4. Do the actual thing (the three-minute part)
  5. Commit and push
  6. Switch back to my branch
  7. Unstash or undo that throwaway commit
  8. 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:

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.

Other Projects