【问题标题】:how to find recent committers of a file in git?如何在 git 中查找文件的最近提交者?
【发布时间】:2011-08-01 12:05:31
【问题描述】:

有没有办法找到最近在 git 中更改了文件的人?

例如,我需要最后 5 个更改此文件的人。我尝试了git annotategit blame,但找不到我想要的确切内容。

【问题讨论】:

    标签: git blame


    【解决方案1】:

    可能不是最有效或最明智的方式,但这似乎可行:

    $ git log <filepath> | grep Author: | cut -d' ' -f2- | uniq | head -n5
    

    这是假设您实际上想要最后 5 个作者,无论他们每个人可能进行了多少次提交。如果您只想要最后 5 次提交,则可以单独使用 git log

    $ git log -5 <filepath>
    

    【讨论】:

      【解决方案2】:

      git shortlog 做你想做的事:

      git shortlog -sne <filename>
      

      【讨论】:

        【解决方案3】:

        试试:

        git log filename
        

        您可以使用日志输出(参见 man git-log)来获取您想要的信息。

        【讨论】:

          【解决方案4】:

          我发现这对于显示单个文件的最后 5 位作者很有用

          git log -n 5 --pretty='format:%an' -- path/to/file
          

          -n &lt;number&gt; - 要显示的提交数(在本例中为作者)

          --pretty='format:%an' - 仅显示作者姓名

          【讨论】:

            【解决方案5】:

            我正在使用

             gitk filename
            

            索斯滕

            【讨论】:

            • 什么是 gitk?需要详细说明吗?
            猜你喜欢
            • 2023-01-03
            • 1970-01-01
            • 2018-08-08
            • 2014-07-14
            • 2017-04-22
            • 2021-08-15
            • 2017-05-07
            • 2011-06-14
            • 2010-10-29
            相关资源
            最近更新 更多