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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With