【问题标题】:How to get the history of commit messages for a given author in a git branch? [duplicate]如何在 git 分支中获取给定作者的提交消息历史记录? [复制]
【发布时间】:2020-01-07 14:50:31
【问题描述】:

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

【问题讨论】:

  • 你到底是什么意思?特定作者提交的所有提交消息?
  • @jonrsharpe 更改为消息。谢谢。

标签: git git-log


【解决方案1】:

git log --author=&lt;author&gt;

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

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

【讨论】:

    【解决方案2】:

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

    例如

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

    【讨论】:

    • 您可以选择使用他们的电子邮件地址。
    • 谢谢贾斯汀。我已经更新了答案。
    【解决方案3】:

    git log --author=&lt;author name pattern&gt;
    详情请查看git log 的手册页。

    【讨论】:

      猜你喜欢
      • 2015-10-19
      • 2011-11-08
      • 2014-11-25
      • 2021-02-07
      • 2016-03-11
      • 2023-03-14
      • 1970-01-01
      • 2014-02-21
      • 1970-01-01
      相关资源
      最近更新 更多