ProjectStack
git

fatal: bad default revision 'HEAD'

Git can't resolve HEAD because there are no commits in the repository yet. HEAD can't point to a commit that doesn't exist.

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

  1. Create the first commit: git add . && git commit -m 'Initial commit'
  2. If you just want to stage files first: git add -A
  3. Check the current HEAD state: cat .git/HEAD
  4. 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.