Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues with Git (HEAD points to an unborn branch (master))

Tags:

git

I have a Git repository with 'master' branch. Some time ago (few months), we stopped using master, and created a new branch that all work is being done on.

I am now setting up source indexing with git, and for some reason i am seeing weird stuff with the new branch:

  1. Running git log fails:

    fatal: bad default revision 'HEAD'

  2. Running git fsck results in this:

    notice: HEAD points to an unborn branch (master) notice: No default references dangling commit 81f11e0b99ad38ecc8502bbed171d2bdfcaa6476

I think that something is not right with this repository/branch which is causing problems with the source indexing scripts.

Any ideas? (Note that the REAL issue here is that the source indexing script fails to get the object id it is trying to lookup using git show, it says that no such object exists).

like image 871
lysergic-acid Avatar asked Dec 18 '11 11:12

lysergic-acid


1 Answers

You don't have to have a master branch but you do have to have a "default" branch in any git repository. In a non-bare repository this the checked out branch, in a bare repository it just means it's the default branch checked out for clones.

This default branch is called HEAD and must always exist in a valid git repository. If you've removed the branch that HEAD was pointing at you can reset to a valid branch it with:

git symbolic-ref HEAD refs/heads/new-main-branch
like image 62
CB Bailey Avatar answered Sep 17 '22 14:09

CB Bailey