git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Cannot checkout a branch / worktree shows multiple branches for the same directory

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 14, 2016, 23:12 UTC
Message-ID
<CAPig+cQXxOLg37au9FQcCC_+=QFnvBRdG6OLBFOTeb5V6rjCiA@mail.gmail.com>
In-Reply-To
<CACB1J8XEXcy+Wewcwx_0UWZbQz-WeWUVnK_yAHw5uTBnr2fpVg@mail.gmail.com>
On Thu, Apr 14, 2016 at 3:51 PM, Krzysztof Voss <k.voss@usask.ca> wrote:
Show 23 quoted lines
> I stumbled upon an interesting problem when checking out a branch.
> I had to switch to a testing branch to merge in some changes from yet
> another branch, but when I tried to check out the testing branch I got
> a message saying that I'm already on the target branch.
>
> I used worktree a few times, but the checkouts were always in their
> own directories.
> It crossed my mind that this behaviour may be related, so I took a
> look at the worktree list and noticed that according to that list
> there are three branches at the same time in one directory.
>
> It may be a conicidence and I have no confidence in saying that these
> issues are related.
> Can someone shed some light on this issue for me?
>
>     $ git --version
>     git version 2.7.0.235.g07c314d
>
>     $ git worktree list
>     /home/k/workspace/moyo  7c5edaa [ticket-22444]
>     /var/home/k/moyo-lsf  349613d (detached HEAD)
>     /home/k/workspace/moyo  265b7f9 (detached HEAD)
>     /home/k/workspace/moyo  c852282 [testing]

Did you manually move any of your worktrees? If so, perhaps this a manifestation of the problem where .git/worktrees/<id>/gitdir got incorrectly "refreshed" following the move. This issue was "addressed" by 618244e (worktree: stop supporting moving worktrees manually, 2016-01-22)[1], which is in git 2.7.2.

Unfortunately, if your gitdir files are already corrupt, upgrading to git 2.7.2 won't recover them; you'll have to fix them manually as described by the documentation update included with 618244e[1].

[1]: http://thread.gmane.org/gmane.comp.version-control.git/284284/focus=284551
Previous: Mike Rappazzo
Message 3 of 3 in “Cannot checkout a branch / worktree shows multiple branches for the same directory”
  1. Krzysztof VossApr 14, 2016
  2. Mike RappazzoApr 14, 2016
  3. Eric SunshineApr 14, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.