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
.