0

I'm trying to fix a problem with git.

When I enter git show HEAD, I got the error fatal : ambiguous 'HEAD': unknown revision or path not in the working tree.

What could I do to fix this problem?

The display of git status is :

git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   script.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    script.txt~
David
  • 149
  • 1
  • 3
  • 14

1 Answers1

6

There is no HEAD because you have not yet made any commits to the repository. HEAD usually points to the currently checked-out commit, but since you have no commits in your tree, HEAD doesn't point to anything, so git show HEAD fails.

jayhendren
  • 4,286
  • 2
  • 35
  • 59
  • This made sense in my situation too. I had a repo without a commit and I wanted to `git reset HEAD^`, but since there wasn't a previous commit, a `HEAD` wasn't created. – Fillip Peyton Apr 12 '17 at 16:49