git status命令表示:文件,文件夾在工作區,暫存區的狀態,下圖就是文件,文件夾三種狀態:
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: bbbb.txt
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: bbbb.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
designpatterns/
"javaDoc/~$it\345\270\270\347\224\250\345\221\275\344\273\244.docx"
Changes to be committed:表示已經從工作區add到暫存區的file(文件或文件夾),可以通過 git restore --staged filename 命令將該file從暫存區移出,只有工作區有該文件,該文件就為Untracked files。
Changes not staged for commit:表示工作區,暫時區都存在的file(文件或文件夾),在工作區進行修改或刪除,但是沒有add到暫存區,可以通過 git add file 命令將變更(修改,刪除)的file add到暫存區,此時該file沒有Changes not staged for commit狀態,也就是Changes not staged for commit將沒有改file的記錄了。可以通過 git restore file 的命令取消在file在工作區的變更,那么暫存區的file內容還是以前的,並且file在Changes not staged for commi狀態下沒有記錄。
Untracked files:表示只在工作區有的file(文件或文件夾),也就是在暫時區沒有該file。
為了演示file的 Untracked files狀態,我們可以在工作區新建一個tt.txt,如下:
為了演示file的Changes to be committed狀態,我們可以將tt.txtadd到暫存區如下;
為了演示file的Changes not staged for commit狀態,我們可以將tt.txt在工作區進行修改如下:
為了演示Changes not staged for commit狀態的file取消在工作區的變更,由於add到暫存區的命令先前演示過就不必要演示了,執行命令 git restore tt.txt如下圖:
為了演示Changes to be committed狀態的file移出暫存區,執行 git restore --staged tt.txt:如下圖: