简化文件状态输出
通常我们都是通过 git status
命令查看文件状态
On branch master_dev
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: dir1/hello.c
new file: hello.o
modified: world.c
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: dir1/hello.c
modified: hello.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
dir1/out/test.o
这样的结果很清晰地描述的文件的状态,但是我们通过 git status -s
简化结果输出,如下图
这几个文件前的符号解释如下
??
表示未跟踪的谁的。- 蓝色的字母表示添加到暂存区的文件。
A
表示未跟踪的文件,现在已经添加到暂存区。M
表示已跟踪的文件,现在修改了,并且添加到了暂存区。 - 红色的字母表示已跟踪的文件被修改了,例如红色
M
表示已跟踪的文件,现在修改了,但是还没有提交到暂存区。
你会发现 dir1/hello.c
的标志是两个M,对比前面的输出结果,你能明白它的意思吗?
心得
虽然说 git status
很简单明了,但是有时候文件多了,一个屏幕大小的空间,显示不了所有的有状态文件,这个时候 git status -s
就体现出作用,但是前提是要看懂状态文件前面的标志。
作为一个有追求的人,我会为了追求效率而使用 git status -s
代替 git status
,并且我为 git status -s
添加了别名 gss
,这样可以提升一点点工作效率,并且看起来很有逼格。