简体   繁体   English

如何从特定提交打印/记录所有git commit消息?

[英]How to print / log all git commits messages from certain commit?

I need to print out all git messages from certain git commit to text file. 我需要从特定的git commit打印出所有git消息到文本文件。

I've looked into answers here on Stackoverflow but couldn't find one that works for conditions I mention. 我在这里研究了关于Stackoverflow的答案,但是找不到适合我提到的条件的答案。

How to do that? 怎么做?

Git does not provide any utility to direct any of its output to a file. Git没有提供任何实用程序将其任何输出定向到文件。

Instead, like virtually all *nix tools, it uses the standard output streams for all of its output, allowing you to use traditional shell output redirection to redirect these streams to a file of your choice. 相反,与几乎所有* nix工具一样,它对所有输出都使用标准输出流 ,从而允许您使用传统的shell输出重定向将这些流重定向到您选择的文件。

In Bash, to redirect the logs for a specific commit, you would use the > to direct standard output to a file: 在Bash中,要重定向特定提交的日志,可以使用>将标准输出定向到文件:

git log <commit_id> > <output_file>

Use following command in git terminal: 在git终端中使用以下命令:

git log --reverse --pretty=%s 487fc18... > ../log.txt

If you want to print all commits for "today" you can use command like: 如果要打印“今天”的所有提交,则可以使用以下命令:

git log --reverse --pretty=%s --since=midnight > ../log.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM