如何生成上个月的 git commit 日志,并将其导出为 CSV?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10418056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I generate a git commit log for the last month, and export it as CSV?
提问by Justin Hymanson
Is there a way to generate a git commit log for the last month, and export it as a CSV file? I'm looking for something I can run from the command line, or a 3rd party app. I'd like the following columns: author, date of commit, subject, file edited and hash.
有没有办法生成上个月的git提交日志,并将其导出为CSV文件?我正在寻找可以从命令行或 3rd 方应用程序运行的东西。我想要以下列:作者、提交日期、主题、文件编辑和哈希。
回答by Simon
You can use the --since
and --pretty
option of git log
, for instance:
您可以使用--since
和 的--pretty
选项git log
,例如:
git log --since="last month" --pretty=format:'%h,%an,%ar,%s' > log.csv
Refer to the PRETTY FORMATS section of the Git log man pagefor more options.
有关更多选项,请参阅Git 日志手册页的 PRETTY FORMATS 部分。
回答by A.Badger
This command creates a formatted CSV containing hash,user,date/time,description,files changed,insertions,deletions
此命令创建一个格式化的 CSV 文件,其中包含哈希、用户、日期/时间、描述、文件更改、插入、删除
git log --pretty=format:'"%h","%an","%aD","%s",' --shortstat --no-merges | paste - - - > log.csv
回答by Marvin Glenn Lacuna
To add, if you want to apply date range, add --after or --before in this format "yyyy-mM-d"
要添加,如果要应用日期范围,请以“yyyy-mM-d”格式添加 --after 或 --before
git log --before="2016-12-1" --pretty=format:'"%h","%an","%ae","%aD","%s",' --shortstat --no-merges | paste - - - > log.csv