problem if branch and top level directory share a name

Bug #701696 reported by drbongo
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
git-core (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: git-core

I am using Ubuntu 10.10. Git-Core 1:1.7.1-1.1ubuntu0.1 - The bug is that if you happen to create a new remote branch which shares it's name with an existing directory in the top level of the git repository, git then seems to get confused and the: git checkout <branch> - command doesn't switch to that branch or turn tracking on (and seems to think it was created from origin/<branch> rather than from refs/remotes/origin/<branch>), which it does correctly if the branch doesn't share a name with an existing top level directory. This can be rectified by running: git checkout --track -b <branch> origin/<branch> - but this confused me for several hours and it was only because I had another repository with the same branch names, but different top level directories where the command worked that it finally dawned on me what the problem was. I then deleted the branch and created a new one with a different name and everything worked as expected. This isn't a serious bug, but it could be very confusing for new users like myself. Perhaps the program can check to make sure you don't try to create a branch with the same name as a top level directory (or visa versa) and say that this is not permitted?

Revision history for this message
Anders Kaseorg (andersk) wrote :

Indeed. Ordinarily you can explicitly disambiguate (see the first few paragraphs of ‘git help cli’): you can specify the branch with ‘git checkout ambiguous --’ or the directory with ‘git checkout -- ambiguous’. However, that doesn’t work when initially setting up a tracking branch:

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/what
$ git ls-files
what/file
$ git checkout what
$ git branch
* master
$ git checkout what --
fatal: invalid reference: what
$ git rm -r what
rm 'what/file'
$ git checkout what
D what/file
Branch what set up to track remote branch what from origin.
Switched to a new branch 'what'

Can you point out this problem to the upstream Git mailing list (<email address hidden>)?

Changed in git-core (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.