|
|
|
|
|
by jfultz
839 days ago
|
|
They can absolutely be checked out to the same commit. They cannot be checked out to the same local branch. But checking out to the same SHA, or even the same remote branch (which, really, is just another name for a given SHA) is just fine. I have two workflows heavily benefitting from worktrees. The first is simple enough...code archeology. I want to do it without disturbing my working tree. Yes, this could have also been done with a separate clone, but I'd have to fetch in that clone, and that's just extra keystrokes. The second is that I like to have a "synthesis" worktree...one that includes PRs I'm reviewing and ones I'm creating. Both benefit from my regularly building and using them (e.g., I might incidentally find bugs through usage I otherwise missed through testing or code-reading, or I might spot pending integration
problems). I don't want multiple build locations...I want to run everything
in one build. But when I've finished developing a PR, need to create a clean version of it from the master branch. In my secondary worktree, I can just cherry-pick commits from my synthesis worktree to produce a clean branch to push.
I could do this in the synthesis worktree, too, but at the cost of
almost certainly forcing a complete rebuild. In a second clone, I'd have
to create patch files because the clone wouldn't have access to the commit
objects for cherry-picking. |
|