Git Worktree
git·command-line·productivityGit worktree is a Git command that lets you check out multiple branches at the same time, each in its own folder — without stashing your changes or cloning the repository again.
It’s great for when you need to jump onto another branch to fix a bug, review a pull request, or kick off a long build, but you don’t want to disturb the work in progress in your main checkout.
Adding a worktree
Create a new branch and check it out into a folder next to your repository:
git worktree add ../new-branch
Or check out an existing remote branch into its own folder. This creates a local branch that tracks the remote branch of the same name from the default origin:
git worktree add ../remote-branch remote-branch
Listing worktrees
See every worktree connected to the repository, along with its folder and checked-out branch:
git worktree list
Removing a worktree
When you’re done, remove the worktree. This deletes the folder and cleans up its administrative files. The branch itself is kept, so you can delete that separately if you no longer need it:
git worktree remove <folder>
Tutorial
GitKraken has a good writeup on git worktree, and this video walks through it: