git clone fails with "warning: remote HEAD refers to nonexistent ref, unable to checkout"

3,912 views
Skip to first unread message

Jayanth S Vasisht

unread,
Jan 9, 2017, 1:43:49 AM1/9/17
to Repo and Gerrit Discussion
We are using Gerrit 2.11.9 hosted on a SuSE Linux 11 box. Recently a git repository was created on this box which was an import of a git repo from another source. On trying to clone this repo, I see the following

$ git clone ssh://myGitServer/a/works/boxschedule
Cloning into 'boxschedule'...
Checking connectivity... done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

The cloned repo is absolutely empty. A git branch -a, git log etc. have nothing to show

At the server side, when I "cd" to the path of the repo, git log does show me lots of commits made on the master branch. git branch -a manages to show me 12 branches in the repo.
$ /a/works/boxschedule.git > cat HEAD
ref: refs/heads/master

$ /a/works/boxschedule.git > du -sh .
4.8M

I am unable to determine why I have a nonexistent ref. Googling for similar errors led me to several articles, but in all of them at least the object count was successful during the clone. I am at my wit's end. Does anyone know why I face this error?

Remy Bohmer

unread,
Jan 9, 2017, 2:08:00 AM1/9/17
to Jayanth S Vasisht, Repo and Gerrit Discussion
Hi,

Does the master branch actually exist in that repo?
And if so, do you the permissions to read it through Gerrit?

Kind regards,

Remy

Op 9 jan. 2017 07:43 schreef "Jayanth S Vasisht" <jaya...@gmail.com>:
--
--
To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jayanth S Vasisht

unread,
Jan 9, 2017, 3:51:34 AM1/9/17
to Remy Bohmer, Repo and Gerrit Discussion
Hello Remy,
  Yes, the master branch does exist.

From the gerrit server hosting the repo
$ /a/works/boxschedule.git> git branch -a
branch1
branch2
* master
branch3

You were right about permissions missing. Once the required read permissions were assigned in gerrit, I still see the same error message. However, git log within the cloned repo now shows the error: fatal: bad default revision 'HEAD', earlier the output was empty!

Jayanth S Vasisht

unread,
Jan 9, 2017, 4:20:44 AM1/9/17
to Remy Bohmer, Repo and Gerrit Discussion
Hello Remy,
  Thank you for your hint, it was indeed the lack of permission in Gerrit which was causing these error messages during clone. Once the permissions were set and the gerrit slave was updated with the master, the clone went through fine.

It is strange to see the "nonexistent ref" error message when there is a lack of permissions. 
Reply all
Reply to author
Forward
0 new messages