Skip to content

How to check out a branch that is checked out on another worktree without switching to it #4622

Answered by stefanhaller
tlang0 asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not very familiar with worktrees, I never use them, but as far as I understand, this is a limitation of git itself. You can't have the same branch checked out in two different worktrees. The only options you have is to switch to the other worktree, or cancel.

If you do want to check it out in the current worktree, then you'd have to switch to that other worktree, check out some other branch there (or maybe a detached head), and then come back to the original one. You should then be able to check out the branch there. Are you suggesting that lazygit should do this for you?

But doing it this way kind of defeats the purpose of worktrees, so I'm wondering why you use them at all then.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tlang0
Comment options

Answer selected by tlang0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants