1

I am getting some weird output on trying to do diff between HEAD and last commit

Fatal: ambiguous argument 'head^': unknown revision or path not in the working tree.
use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

While using git diff <sha> HEAD^, I get the error

warning: ignoring dangling symref head. warning: ignoring dangling symref head.
fatal: ambiguous argument 'head^': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

am I missing something?

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
  • 2
    try `git diff HEAD^` instead of `git diff head^`. – jlahd Jan 19 '14 at 22:25
  • warning: ignoring dangling symref head. warning: ignoring dangling symref head. fatal: ambiguous argument 'head^': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' – Ciasto piekarz Jan 19 '14 at 22:41

1 Answers1

0

Okay, I think there can be 2 possible reasons here

1) Issue here is, you are trying to do a git diff <sha> head^

In this case, you need to correct your command to git diff <sha> HEAD^. Note the upper case characters. Check out this question to read more about HEAD.

2) You are trying git diff <sha> HEAD^ and are still getting the error message. In this case, I think you have only one commit in your repository. While the sha points to that lone commit, your HEAD also happens to point at that first commit, and HEAD^ happens to point at the commit before that, which doesn't exist, so the error.

Another possibility here is that someone upstream has created a dangling symref (a dangling object) while doing a merge or a git reset or a git rebase. This should be removable by doing a git prune.

Community
  • 1
  • 1
Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186