也許你以前在創建git存儲庫時第一次添加和提交?
我能夠與重現此:
durrantm.../aaa$ git init
Initialized empty Git repository in /home/durrantm/play/aaa/.git/
durrantm.../aaa$ l
total 16
drwxrwxr-x 14 durrantm 4096 Oct 31 22:28 ../
-rw-rw-r-- 1 durrantm 11 Oct 31 22:29 ggg
drwxrwxr-x 3 durrantm 4096 Oct 31 22:29 ./
drwxrwxr-x 7 durrantm 4096 Oct 31 22:29 .git/
durrantm.../aaa$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# ggg
nothing added to commit but untracked files present (use "git add" to track)
durrantm.../aaa$ git add .
durrantm.../aaa$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: ggg
#
durrantm.../aaa$ git commit
[master (root-commit) 953c83f] new
1 file changed, 1 insertion(+)
create mode 100644 ggg
durrantm.../aaa$ l
total 16
drwxrwxr-x 14 durrantm 4096 Oct 31 22:28 ../
-rw-rw-r-- 1 durrantm 11 Oct 31 22:29 ggg
drwxrwxr-x 3 durrantm 4096 Oct 31 22:29 ./
drwxrwxr-x 8 durrantm 4096 Oct 31 22:29 .git/
durrantm.../aaa$ git init
Reinitialized existing Git repository in /home/durrantm/play/aaa/.git/
durrantm.../aaa$ l
total 16
drwxrwxr-x 14 durrantm 4096 Oct 31 22:28 ../
-rw-rw-r-- 1 durrantm 11 Oct 31 22:29 ggg
drwxrwxr-x 3 durrantm 4096 Oct 31 22:29 ./
drwxrwxr-x 8 durrantm 4096 Oct 31 22:30 .git/
durrantm.../aaa$ git add .
durrantm.../aaa$ git status
# On branch master
nothing to commit (working directory clean)
durrantm.../aaa$
durrantm.../aaa$ git commit
# On branch master
nothing to commit (working directory clean)
注意如何git add .
後有nothing to commit
在最後,你所看到的。
一個「修復」是刪除的Git倉庫並重新開始,當你這樣做你提交最終爲正常,如:
durrantm.../aaa$ rm -rf .git/
durrantm.../aaa$ l
total 12
drwxrwxr-x 14 durrantm 4096 Oct 31 22:28 ../
-rw-rw-r-- 1 durrantm 11 Oct 31 22:29 ggg
drwxrwxr-x 2 durrantm 4096 Oct 31 22:34 ./
durrantm.../aaa$ git init
Initialized empty Git repository in /home/durrantm/play/aaa/.git/
durrantm.../aaa$ l
total 16
drwxrwxr-x 14 durrantm 4096 Oct 31 22:28 ../
-rw-rw-r-- 1 durrantm 11 Oct 31 22:29 ggg
drwxrwxr-x 3 durrantm 4096 Oct 31 22:34 ./
drwxrwxr-x 7 durrantm 4096 Oct 31 22:34 .git/
durrantm.../aaa$ git add .
durrantm.../aaa$ git commit
[master (root-commit) 380863a] wewew
1 file changed, 1 insertion(+)
create mode 100644 ggg
我刪除了初步承諾,當我意識到庫我承諾我的主目錄中的所有內容。我也做了一個'git reset --hard'來消滅之前的提交。鑑於它所說的「重新初始化......」,我描述的行動是否沒有任何效果? – LearningHowToCode