“git show HEAD”导致“致命:模棱两可的‘HEAD’:未知修订版或路径不在工作树中”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41194362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:30:25  来源:igfitidea点击:

"git show HEAD" results in "fatal : ambiguous 'HEAD': unknown revision or path not in the working tree"

git

提问by J.G

I'm trying to fix a problem with git.

我正在尝试解决git.

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

当我输入时git show HEAD,出现错误fatal : ambiguous 'HEAD': unknown revision or path not in the working tree

What could I do to fix this problem?

我能做些什么来解决这个问题?

The display of git statusis :

的显示git status为:

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~

回答by jayhendren

There is no HEADbecause you have not yet made any commits to the repository. HEADusually points to the currently checked-out commit, but since you have no commits in your tree, HEADdoesn't point to anything, so git show HEADfails.

没有,HEAD因为您尚未对存储库进行任何提交。 HEAD通常指向当前签出的提交,但由于您的树中没有提交HEAD,因此不指向任何内容,因此git show HEAD失败。