我想要一个像这样的旗帜:
git log --pretty="format: %added %removed %cd"
据我所知,这些标志在 format:<string>
中不可用。 .
我读过 the documentation它似乎不存在,但包含它似乎是一件显而易见的事情,我想知道我是否遗漏了什么。
最佳答案
如果您需要编写脚本以显示您想要的内容,最接近的 native git 命令显示在 git log
中每个文件添加/删除的行是:
git log --pretty=tformat: --numstat
与:
--numstat
Similar to
--stat
, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly.
For binary files, outputs two - instead of saying0 0
.
This gist通过 KOGI提供了此类脚本的一个示例(不完全是您所追求的,但您已经了解了总体思路)
git log --pretty=tformat: --numstat $@ "`git merge-base HEAD develop`..HEAD" | gawk '{ adds += $1 ; subs += $2 ; net += $1 - $2 ; gross += $1 + $2 ; commits += 1 } END { print "total commits\tadded loc\tremoved loc\tgross loc\tnet loc\n"; printf "%d\t%d\t%d\t%d\t%d\n", commits, adds, subs, gross, net }' | column -s $'\t' -t
关于Git log --pretty=format 添加和删除了行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19283764/