Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: fatal: bad default revision 'HEAD' with all new repos

Tags:

git

The issue was a heavy amount of shell customization.

If I try to create a new repo with git init it gives me fatal: bad default revision 'HEAD' twice.

If I do git log it gives me the same error three times.

I have deleted ~/.git , ~/.config , and ~/.gitconfig based on other answers I've found stating I might have created the repo in my home directory. The only repo that doesn't give me this issue is the one I cloned from someone else.

I'm unsure what I did besides deleting anything in my home directory with git info in it.

As per request:

jsw:~ jsw$ mkdir test
jsw:~ jsw$ cd test
jsw:test jsw$ git init
Initialized empty Git repository in /Users/jsw/test/.git/
fatal: bad default revision 'HEAD'
fatal: bad default revision 'HEAD'
jsw:test(master|23448707m) jsw$ cat .git/HEAD
ref: refs/heads/master
fatal: bad default revision 'HEAD'
fatal: bad default revision 'HEAD'


jsw:~ jsw$ git status
fatal: Not a git repository (or any of the parent directories): .git
like image 902
Ravenous Avatar asked Dec 25 '22 06:12

Ravenous


2 Answers

You maybe getting this error because you don't have any commits on your HEAD revision, so when you make a git log it won't find any commit on the HEAD.

Please try:

mkdir test
cd test
git init
git commit -m 'Initial Commit' --allow-empty
git log
like image 71
eslimaf Avatar answered Dec 27 '22 20:12

eslimaf


You ran cat .git/HEAD and it replied:

ref: refs/heads/master
fatal: bad default revision 'HEAD'
fatal: bad default revision 'HEAD'

Since cat is not a git command and doesn't care about your HEAD, I suspect that you have configured your shell to do something like print the name of the current branch.

In fact, looking at your shell prompt:

jsw:test(master|23448707m) jsw$

I'm certain of it.

Either turn off whatever shell magic you are trying to perform, fix it so that it knows how to deal with new repositories, or simply cope with the error messages until you've made your first commit.

like image 26
Edward Thomson Avatar answered Dec 27 '22 19:12

Edward Thomson