默认的 git status 信息挺全,但有时候只是想看哪些文件改了、哪些是新文件,用 --short 会更省眼睛。
环境:Git 2.30+。可以随便开个目录试:
mkdir git-status-short-demo && cd git-status-short-demo
git init
printf 'hello\n' > app.txt
git add app.txt
git commit -m 'init'
printf 'hello world\n' > app.txt
printf 'note\n' > draft.md
git status --short
大概会看到类似这样:
M app.txt
?? draft.md
前面的 M 是已修改,?? 是 Git 还没跟踪的新文件。
我觉得它比较适合提交前快速扫一眼,确认没有把临时文件混进去。真要看完整说明,再跑普通的 git status 就行。