git status命令表示:文件,文件夹在工作区,暂存区的状态,下图就是文件,文件夹三种状态:
Changes to be committed: (use “git restore --staged …” to unstage) new file: bbbb.txt
Changes not staged for commit: (use “git add …” to update what will be committed) (use “git restore …” to discard changes in working directory) modified: bbbb.txt
Untracked files: (use “git add …” 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,如下: ![在这里插入图片描述](https://img-blog.csdnimg.cn/528d897ca7464b2e91e7caf48213d3bd.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55O255uW55qE54yq54yq5L6g,size_17,color_FFFFFF,t_70,g_se,x_16) 为了演示file的Changes to be committed状态,我们可以将tt.txtadd到暂存区如下;
![在这里插入图片描述](https://img-blog.csdnimg.cn/681f967cfb584f15bdb1b776f2ede0e9.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55O255uW55qE54yq54yq5L6g,size_16,color_FFFFFF,t_70,g_se,x_16) 为了演示file的Changes not staged for commit状态,我们可以将tt.txt在工作区进行修改如下:
![在这里插入图片描述](https://img-blog.csdnimg.cn/403ecce10b994e65871f21b163b942db.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55O255uW55qE54yq54yq5L6g,size_16,color_FFFFFF,t_70,g_se,x_16) 为了演示Changes not staged for commit状态的file取消在工作区的变更,由于add到暂存区的命令先前演示过就不必要演示了,执行命令 git restore tt.txt如下图: ![在这里插入图片描述](https://img-blog.csdnimg.cn/a00e7a417e804ef291f25ed865825c9a.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55O255uW55qE54yq54yq5L6g,size_16,color_FFFFFF,t_70,g_se,x_16) 为了演示Changes to be committed状态的file移出暂存区,执行 git restore --staged tt.txt:如下图:
![在这里插入图片描述](https://img-blog.csdnimg.cn/c6a493a90cd9410883989e15e34f46af.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55O255uW55qE54yq54yq5L6g,size_17,color_FFFFFF,t_70,g_se,x_16)
|