git fetch fails silently if remote repo is not checked out on any branch
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
git (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Reproduction steps:
1) Create a git repository that has no branches at all (detached HEAD and no branches).
2) Let this repository serve as a remote to another repository.
Now, 'git fetch <name>' fails silently.
Notes:
1) If it cannot succeed, let it fail loudly at least, if possible providing a useful hint.
2) A repository with no branches at all is not that rare thing as one might think - e.g. clone AOSP (Android Open Source Project) - every one of its git repos is checked out at some point with no branches at all.
3) I have built git version 2 - the bug is still there.
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: git 1:1.9.1-1
ProcVersionSign
Uname: Linux 3.13.0-29-generic x86_64
NonfreeKernelMo
ApportVersion: 2.14.1-0ubuntu3.2
Architecture: amd64
CurrentDesktop: Unity
Date: Sun Jun 29 18:25:16 2014
InstallationDate: Installed on 2011-10-23 (980 days ago)
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111011)
SourcePackage: git
UpgradeStatus: Upgraded to trusty on 2014-05-25 (35 days ago)
I believe Git is working as designed. You asked it to fetch the empty set of branches, so that’s what it did.
It is slightly confusing that, in the normal non-detached case, ‘git clone’ creates the refs/remotes/ origin/ HEAD symref pointing to the remote’s default branch; however, even in this case, ‘git fetch’ does not update it.
If you think the design is wrong, you may want to bring this up with the upstream developers.
But I don’t believe that the AOSP repositories have no branches. They look completely normal to me.
$ git clone https:/ /android. googlesource. com/platform/ packages/ apps/Email origin/ HEAD -> origin/master origin/ donut-release origin/ donut-release2 origin/ eclair- passion- release origin/ master origin/ tools_r20 origin/ tools_r21 origin/ tools_r22 origin/ tools_r22. 2
$ cd Email
$ git branch -a
* master
remotes/
remotes/
remotes/
remotes/
[…]
remotes/
remotes/
remotes/
remotes/
remotes/
I think the answer is that you should not create repositories with no branches.