Common causes
- The repository was just initialized with git init and has no commits
- All commits were removed with a hard reset to an empty state
- The .git/HEAD file is corrupt or points to a non-existent ref
- Running git log, git diff HEAD, or similar commands before the first commit
How to fix it
- Create the first commit: git add . && git commit -m 'Initial commit'
- If you just want to stage files first: git add -A
- Check the current HEAD state: cat .git/HEAD
- If HEAD is corrupt, re-init is usually faster than trying to repair: back up files, rm -rf .git, git init
Example
fatal: bad default revision 'HEAD'Running git log on a freshly initialized repository with no commits
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
