2021年3月29日星期一

Git to correct branch and worktree mismatch

Following up on '<Branch>' is already checked out at '</other/location>' in git worktrees

I'm getting the "Branch is already checked out at different worktree" error when my branch and worktree mismatched:

I have to use git worktree remove to remove my 1.2T worktree for now, but I'd like to know what's the best way to fix it in the future.

I have branch and worktree setup like the following:

  • /path/master corresponds to my git master branch
  • /path/release-a corresponds to my git release-a branch
  • /path/release-b corresponds to my git release-b branch

So on and so forth. I had it like that for years, until a few days ago I click and change a worktree branch in MS VS by mistake. Now my branch and worktree is like this:

  • /path/release-a is using my git release-b branch
  • /path/release-b is using my git release-b branch

Now I cannot change it back in MS VS. Trying to switch branch within the worktree will get me:

fatal: '<branch>' is already checked out at '</other/location>'  

Any better way other than git worktree remove please.

https://stackoverflow.com/questions/66787237/git-to-correct-branch-and-worktree-mismatch March 25, 2021 at 02:33AM

没有评论:

发表评论