2016-12-16 188 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'。 –