If you constantly find yourself using “git stash” while working on a project, or, even worse – have multiple copies of the same project cloned on the same machine, “git worktree” might be a much better alternative for you.
Manage multiple working trees attached to the same repository.
A git repository can support multiple working trees, allowing you to check out more than one branch at a time. With
git worktree adda new working tree is associated with the repository. This new working tree is called a “linked working tree” as opposed to the “main working tree” prepared by “git init” or “git clone”. A repository has one main working tree (if it’s not a bare repository) and zero or more linked working trees.
When you are done with a linked working tree you can simply delete it.
Here are a few links to get you started:
- What would I use git-worktree for?
- The 2016 Git Retrospective: Worktrees
- Git 2.5, including multiple worktrees and triangular workflows
- Parallelize Development Using Git Worktrees
- git worktree notes