如何获取 git 分支中给定作者的提交消息历史记录?

How to get the history of commit messages for a given author in a git branch?

我想获取 git 分支中给定作者的提交消息历史记录。除了通过编程解析日志,还有什么简单的方法可以实现吗?

更新:

以下是为我做同样的事情:

git log --author='some author' --pretty=oneline --abbrev-commit
git log --author='some author' --oneline

git log --help 提及如下:

   Commit Formatting
       --pretty[=<format>], --format=<format>
           Pretty-print the contents of the commit logs in a given format, where <format> can be one of oneline, short, medium, full, fuller, email, raw and
           format:<string>. See the "PRETTY FORMATS" section for some additional details for each format. When omitted, the format defaults to medium.

           Note: you can specify the default pretty format in the repository configuration (see git-config(1)).

       --abbrev-commit
           Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix. Non default number of digits can be specified
           with "--abbrev=<n>" (which also modifies diff output, if it is displayed).

           This should make "--pretty=oneline" a whole lot more readable for people using 80-column terminals.

       --no-abbrev-commit
           Show the full 40-byte hexadecimal commit object name. This negates --abbrev-commit and those options which imply it such as "--oneline". It also
           overrides the log.abbrevCommit variable.

       --oneline
           This is a shorthand for "--pretty=oneline --abbrev-commit" used together.

您必须提供在 GIT 存储库中注册的作者姓名。或者作者的电子邮件地址也可以。

例如

git log --author='Bharat Biswal'
git log --author='bharat.biswal@gmail.com'

git log --author=<author name pattern>
查看 git log 的手册页了解详细信息。

git log --author=<author>

如果说你正在寻找 adam Brown 提交

git log --author="adam"

git log --author=adam

git log --author=Brown

也可以。如果不需要任何空格,引号是可选的。

如果您打算搜索所有分支而不仅仅是当前提交在您的存储库中的祖先,请添加 --all。

所以要列出 adam 或 damian 的提交,你可以像这样做一个正则表达式:

git log --author="\(damian\)\|\(adam\)"

git log --committer="\(damian\)\|\(amit\)"