Git 日志输出到 XML、JSON 或 YAML? [英] Git log output to XML, JSON, or YAML?

查看:34
本文介绍了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

另见:

这篇关于Git 日志输出到 XML、JSON 或 YAML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆