Read more

Parallelize Development Using Git Worktrees

Julian
February 16, 2021Software engineer at makandra GmbH

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

Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot

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.

Posted by Julian to makandra dev (2021-02-16 20:23)