是否可以更改 git status
的输出,以便每个文件扩展名只显示一行?例如,
M *.java -> 12
D *.html -> 2
M *.md -> 1
我在 Unix 上,所以一些 grep 魔法也可以。
最佳答案
试试这个:
git status -s | awk '{print $2}' \
| sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' \
| uniq -c
地点:
awk '{print $2}'
- 匹配更新的文件
sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/'
- 提取文件扩展名
uniq -c
- 计算计数
关于Git 状态摘要(按文件扩展名),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45676542/