I admit I’ve never once used a Git Worktree. But Nick Taylor has a pretty good intro that compels me. (Nick credits bashbunni for her own intro).
Git worktrees let you check out multiple branches from the same repository simultaneously, each in its own working directory. Instead of constantly switching between branches with
git checkout
, you can have separate directories for different features, bug fixes, or experiments.
So instead of just one folder on your computer representing your project, you can have multiple folders, each representing different branches of the same repo. That just feels weird to me, hence never having tried it. But if…
- You do a lot of branch-hopping
- You don’t like committing half-done work
- You don’t like
git stash
… Git Worktrees might be for you. The reason I’m a little compelled at the moment is that I use GitHub Desktop and stashing kinda sucks in it.