首页 > 解决方案 > 如何在 git 分支中获取给定作者的提交消息历史记录?

问题描述

我想在 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.

标签: gitgit-log

解决方案


git log --author=<author>

如果说你正在寻找亚当布朗提交

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\)"


推荐阅读