使用git status命令有三种结果
1.文件被修改但是未提交也位添加到仓库会显示:
下面的命令告诉我们,readme.txt被修改过了,但还没有准备提交的修改。
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
2.提交文件到仓库执行了add未执行commit操作,此时再次git status会显示:
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: readme.txt
git status告诉我们,将要被提交的修改包括readme.txt,下一步,就可以放心地提交了:
3.执行了commit之后再次使用git status会显示:
$ git status
On branch master
nothing to commit, working tree clean
Git告诉我们当前没有需要提交的修改,而且,工作目录是干净(working directory clean)的。
***************以上是git status命令的三种显示形式代表了三种不同的状态*************
小结:
要随时掌握工作区的状态就使用 git status命令查看;
如果git告诉文件被修改可以使用git diff查看修改内容