|
|
|
|
|
by Too
1577 days ago
|
|
Git could hide this for you and just make it look like you cloned the repo twice. What happens if you make a commit in dir1 and dir2 is on the same branch. Absolutely nothing, until you fetch, and worktrees could work the same way. If there is any ambiguity left you could prefix the branch names similar to the remotes origin/master, worktree2/master. The only sane way to use worktrees today is, like you say, with detached heads. Which well…isn’t that sane for many other reasons. |
|
I did not say that was the only sane way to use worktrees. I frequently use them for separate strands of ongoing work (on separate branches per work strand, named appropriately). Less common (for me) is the use case of easy reference to older versions, with more ephemeral worktrees checking out a tag, a new branch (created for the purpose, and short-lived), or a particular commit (viewed as a detached HEAD).