git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Cannot checkout a branch / worktree shows multiple branches for the same directory
@ 2016-04-14 19:51 Krzysztof Voss
  2016-04-14 23:11 ` Mike Rappazzo
  2016-04-14 23:12 ` Eric Sunshine
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Voss @ 2016-04-14 19:51 UTC (permalink / raw)
  To: git

Hi,

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 status -uno -sb
    ## ticket-22444
    M src/core/parsers/ParserBase.py
    M src/core/parsers/test/ParserBase_test.py

    $ git stash
    Saved working directory and index state WIP on ticket-22444:
7c5edaa #22444 refactoring
    HEAD is now at 7c5edaa #22444 refactoring

    $ git co testing
    fatal: 'testing' is already checked out at '/home/k/workspace/moyo'

    $ pwd
    /home/k/workspace/moyo

    $ git branch | grep '*'
    * ticket-22444

    $ 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]

    $ uname -a
    Linux k 3.13.0-83-generic #127-Ubuntu SMP Fri Mar 11 00:25:37 UTC
2016 x86_64 x86_64 x86_64 GNU/Linux

    $ cat /etc/lsb-release
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=14.04
    DISTRIB_CODENAME=trusty
    DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"


Thanks,
Krzysztof

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cannot checkout a branch / worktree shows multiple branches for the same directory
  2016-04-14 19:51 Cannot checkout a branch / worktree shows multiple branches for the same directory Krzysztof Voss
@ 2016-04-14 23:11 ` Mike Rappazzo
  2016-04-14 23:12 ` Eric Sunshine
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Rappazzo @ 2016-04-14 23:11 UTC (permalink / raw)
  To: Krzysztof Voss; +Cc: Git List, Nguyễn Thái Ngọc

On Thu, Apr 14, 2016 at 3:51 PM, Krzysztof Voss <k.voss@usask.ca> wrote:
> Hi,
>
> 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 status -uno -sb
>     ## ticket-22444
>     M src/core/parsers/ParserBase.py
>     M src/core/parsers/test/ParserBase_test.py
>
>     $ git stash
>     Saved working directory and index state WIP on ticket-22444:
> 7c5edaa #22444 refactoring
>     HEAD is now at 7c5edaa #22444 refactoring
>
>     $ git co testing
>     fatal: 'testing' is already checked out at '/home/k/workspace/moyo'
>
>     $ pwd
>     /home/k/workspace/moyo
>
>     $ git branch | grep '*'
>     * ticket-22444
>
>     $ 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]

This looks a lot like the `update_linked_gitdir()` bug that (I
thought) was fixed[1].  Is
it possible that you had this problem since before the bug was fixed
and are just
noticing it now?

If you look in '/home/k/workspace/moyo/.git/worktrees/`  I suspect
that there are 3 dirs
in there, two of which have a file 'gitdir' which have the contents
'.git'.  These _should_
instead point to the '.git' file in your other work trees.  It would
be nice to know the last
time that those bad worktrees were updated.

If you know where the other worktrees are located, then you should be able to
manually update this file in each of the worktree dirs.
Alternatively, you can manually
remove the bad linked worktrees (`rm -r .git/worktrees/bad_wt`).

[1] http://thread.gmane.org/gmane.comp.version-control.git/284284

>
>     $ uname -a
>     Linux k 3.13.0-83-generic #127-Ubuntu SMP Fri Mar 11 00:25:37 UTC
> 2016 x86_64 x86_64 x86_64 GNU/Linux
>
>     $ cat /etc/lsb-release
>     DISTRIB_ID=Ubuntu
>     DISTRIB_RELEASE=14.04
>     DISTRIB_CODENAME=trusty
>     DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"
>
>
> Thanks,
> Krzysztof
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cannot checkout a branch / worktree shows multiple branches for the same directory
  2016-04-14 19:51 Cannot checkout a branch / worktree shows multiple branches for the same directory Krzysztof Voss
  2016-04-14 23:11 ` Mike Rappazzo
@ 2016-04-14 23:12 ` Eric Sunshine
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sunshine @ 2016-04-14 23:12 UTC (permalink / raw)
  To: Krzysztof Voss; +Cc: Git List

On Thu, Apr 14, 2016 at 3:51 PM, Krzysztof Voss <k.voss@usask.ca> wrote:
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-14 23:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-14 19:51 Cannot checkout a branch / worktree shows multiple branches for the same directory Krzysztof Voss
2016-04-14 23:11 ` Mike Rappazzo
2016-04-14 23:12 ` Eric Sunshine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).