Weekly Git Command #5: git worktree

Sometimes, while working on a project, you need to work on two branches at the same time.
Before I learned about git worktree, my workflow was messy:
Stash changes
Switch branches
Make changes
Switch back and pop the stash
This worked, but it was slow and error-prone. That’s when I discovered git worktree.
What git worktree does
git worktree allows you to have multiple working directories linked to the same repository.
Instead of stashing or cloning the repo twice, you can work on different branches simultaneously, all in separate folders, without losing context.
Basic usage
Add a new worktree
git worktree add ../feature-branch feature
This:
Creates a new folder ../feature-branch
Checks out the feature branch in that folder
Lets you work on it independently from your main working directory
List your worktrees
git worktree list
Output might look like:
/home/user/project 123abc [main]
Remove a worktree
Once you’re done:
git worktree remove ../feature-branch
This cleans up the extra folder safely.
Why it’s useful
Work on multiple features at the same time without stashing constantly
Test changes on a branch while keeping your main branch clean
Avoid creating multiple clones of the same repository
Once you start using git worktree, it feels like a workflow game-changer.
Final thoughts
git worktree is one of those underrated Git commands that makes life easier for developers.
It’s simple, safe, and perfect for handling multiple branches without messy stashing or repeated clones.
This post is part of my Weekly Git Command series, sharing commands I’ve been learning while contributing to Git via Outreachy.
Next week, we’ll explore git blame -w, a command that helps you understand who made changes and why.




