3 ms·
You can absolutely check it out in multiple places. You get a warning because the behavior is unintuitive. If you want to force it to do it anyways you just us
by CuriousCosmic 3y ago
You can absolutely check it out in multiple places. You get a warning because the behavior is unintuitive.
If you want to force it to do it anyways you just use -f/--force.
When you check out a branch, the expectation is that the working tree is in sync with the current head commit. If you check out the same branch in multiple places, then if you commit on worktree a, worktree b won't say that it's still on the old commit, it'll just say that the diff between the current head and the contents of worktree b's working directory are a bunch of uncommitted changes. That's why it's unintuitive.
This is clearly not the intended behavior for most users when they want to check out the same branch in multiple places. They want to check out a given commit that happens to be the head of the current branch in multiple places. To do that you use --detach so that the worktree head points to the commit rather than the branch itself.