Search code examples
gitgitolite

New repo added to gitolite on server, getting "unable to checkout" when try to push there


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

Solution

  • 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.