It can be handy to have two checkouts of a repo. One is the primary one (A) for working in. And the other is the “spare” (B).
This can be useful in a number of situations:
- You’re in the middle of a rebase in A and want to quickly reference something in another branch. Instead of having to mess up your rebase state, or go to github, you just go to B.
- You’re code reviewing an intense refactor of an API. It can be handy to quickly flip back and forth between the versions of the codebase before and after the API change to get a better sense of what changes. Sometimes the diff isn’t quite enough.
- You’re code reviewing one branch and want to quickly code review another in a way that’s “immutable” to your work environment.
- If you want to quickly flip back and forth between builds of two different branches.
Indeed, that is why we have https://git-scm.com/docs/git-worktree
I would so like to use this feature, but always got tripped up in the past because two worktrees cannot be on the same branch iirc.
Fair. I guess it depends on ones mental model, for me branches are simple pointers to commits.
Either way, multiple checkouts or multiple worktrees are definitely a productivity increase.