查看文件當(dāng)前處于什么狀態(tài)的命令為:git status 有送。一般倉庫中的文件可能存在于這三種狀態(tài):
1)Untracked files → 文件未被跟蹤;
2)Changes to be committed → 文件已暫存囱晴,這是下次提交的內(nèi)容澳泵;
3) Changes bu not updated → 文件被修改实愚,但并沒有添加到暫存區(qū)。如果 commit 時(shí)沒有帶 -a 選項(xiàng)兔辅,這個(gè)狀態(tài)下的文件不會(huì)被提交腊敲。
值得注意的是,同一個(gè)文件有可能同時(shí)出現(xiàn)在第二和第三種狀態(tài)中维苔。例如:
$git add NewFile
$vim NewFile # 編輯該文件
$git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: NewFile
Changed but not updated:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: NewFile
這時(shí)只需要將 NewFile 再添加一次就可以了碰辅。
$git add NewFile
$git status