1

I've got a server set up with a handful of git repositories using gitolite.

I added a new repository by updating gitolite.conf to have an entry for the new repo, and pushing (as described here).

I then added a git remote entry on my local machine so that I can push to the new gitolite repo.

When I try and push any branch other than master there, I see the following error:

remote: warning: remote HEAD refers to nonexistent ref, unable to checkout
Sam
  • 5,997
  • 5
  • 46
  • 66
  • 1
    Actually, I realise now that the failed clone was happening in a git hook which was attempting to clone *from* the gitolite repo (as part of copying the code from the repo into a publicly-visible folder). So I'm not sure whether gitolite itself actually hits this problem. But I'll leave this Q&A up as the `git symbolic-ref` command (see my answer) is indeed the one to use for `nonexistent ref` errors! – Sam Dec 04 '14 at 11:43

1 Answers1

1

The issue is that gitolite repos default to using master as their default branch, and so it was looking in the master branch for the refs that I was pushing, and they weren't there.

I found the way to fix that here - using the git symbolic-ref command. As that post explains, the command can be run via gitolite itself in newer versions, or you can log into the remote server and do it there.

In my case, I went to my new repo on the server (i.e. /home/git/repositories/my_new_one.git) and ran git symbolic-ref HEAD refs/heads/develop, switching the default branch to develop.

I could now push the develop branch there as I needed.

Community
  • 1
  • 1
Sam
  • 5,997
  • 5
  • 46
  • 66