如何打印/记录来自某个提交的所有 git 提交消息?

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

我需要打印出某些 git 提交到文本文件的所有 git 消息。

我已经在 Whosebug 上查看了答案,但找不到适合我提到的条件的答案。

怎么做?

在 git 终端中使用以下命令:

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

如果你想打印 "today" 的所有提交,你可以使用如下命令:

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

Git 不提供任何实用程序将其任何输出定向到文件。

相反,与几乎所有 *nix 工具一样,它使用 standard output streams for all of its output, allowing you to use traditional shell output redirection 将这些流重定向到您选择的文件。

在 Bash 中,要重定向特定提交的日志,您可以使用 > 将标准输出定向到文件:

git log <commit_id> > <output_file>