Parallelize Development Using Git Worktrees

Updated . Posted . Visible to the public. Repeats.

You can use git worktree to manage multiple working trees attached to the same repository. But why should I use git worktree?

You can use more than one working tree to ...

... run tests while working on another branch
... compare multiple versions
... work on a different branch without disturbing your current branch

Creating a new working tree is as simple as creating a new branch. You only need to execute git worktree add <path> <branch>. When you are done, you can remove the working tree with git worktree remove <Worktree>. For more details see git-worktree Show archive.org snapshot .

Warning

Worktrees share the git directory (a new worktree points to the .git directory of the original directory). They share one git stash for example. Therefore you should be careful not to destroy stashes or branches from a different worktree.

Julian
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Julian to makandra dev (2021-02-16 19:23)