Git 日志输出到 XML、JSON 或 YAML?

问题描述:

这是一个非常简单的问题:作为一个 Git 新手,我想知道是否有办法将我的 git 日志输出到文件中,最好是某种序列化格式,如 XML、JSON 或 YAML.有什么建议吗?

This is a pretty simple question: as a Git newbie I was wondering if there's a way for me to output my git log to a file, preferably in some kind of serialized format like XML, JSON, or YAML. Any suggestions?

输出到文件:

git log > filename.log

指定一种格式,就像你想要一行一样

To specify a format, like you want everything on one line

git log --pretty=oneline >filename.log

或者您希望它是一种通过 sendmail 之类的程序通过电子邮件发送的格式

or you want it a format to be emailed via a program like sendmail

git log --pretty=email |email-sending-script.sh

要生成 JSON、YAML 或 XML,您似乎需要执行以下操作:

to generate JSON, YAML or XML it looks like you need to do something like:

git log --pretty=format:"%h%x09%an%x09%ad%x09%s"

这个要点(不是我的)完美地格式化了 JSON 输出:https://gist.github.com/1306223

This gist (not mine) perfectly formats output in JSON: https://gist.github.com/1306223

另见: