Git log --pretty=format 添加和删除了行?

标签 git git-log

我想要一个像这样的旗帜:

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 saying 0 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/

相关文章:

git - 删除 GitHub 草稿版本的命令

git - 当我推送到 GitHub 时如何处理 secret API key ,以便我的项目在克隆 repo 协议(protocol)时仍然有效?

git - 删除gitlab上的提交

git - 删除 git branch -a 列出的分支

所有分支(甚至远程)的范围的 Git 日志

Git - 为什么在已删除文件上运行命令时需要双破折号?

Git:格式化为正确自动着色 %d

Git:相当于 `--full-history` 和 `git bisect` 的 `git blame`

git - 如何嵌套 git 存储库;获取并 merge

bash - 每次提交的提交中的所有文件的列表