2016-12-16 248 views
0

我试图修复git的问题。“git show HEAD”结果为“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

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

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~ 
+0

'git status'的输出是什么? – Jakuje

回答

1

没有HEAD因为你还没有作出任何承诺到库中。 HEAD通常指向当前签出的提交,但由于您的树中没有提交,因此HEAD不指向任何内容,因此git show HEAD失败。

+0

这也适用于我的情况。我有一个没有提交的repo,我想'git reset HEAD ^',但由于没有提交,因此没有创建'HEAD'。 –