简体   繁体   中英

git diff between HEAD and last commit gives Warning: ignoring dangling symref

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM