It’s 2024, I Haven’t Used Git Worktree Yet

David Lee
4 min readMar 25, 2024

I am today years old when I learned I could have multiple git working trees active at the same time.

Well, I gotta confess, Git worktree was totally off my radar until now. But hey, no shame here! Turns out, even the mighty Guido van Rossum was in the dark about it back in 2021.

So, I figure, if I’m only three years behind the Python guru himself, I must be making some serious progress!

What is Git Worktree?

First you need to create a branch before working with git worktree:

git branch feature

Let’s consider a scenario where you’re working on a feature in this branch called feature, and suddenly you need to fix a critical bug in the master branch.

Without git worktree, you would have to stash or commit your changes in the feature branch, switch to the master branch, fix the bug, commit the fix, switch back to the feature branch, and then unstash or checkout your changes. This can be a bit cumbersome, especially if you need to switch back and forth multiple times.

--

--