【问题标题】:How to get all the authors of a group of files in Git?如何在 Git 中获取一组文件的所有作者?
【发布时间】:2020-08-22 10:09:09
【问题描述】:

我想从 git blame/bash/awk 大师那里得到一些帮助。我想列出所有的人,他们出现在特定文件组中每个文件的 git blame 中。示例:

  • 文件 A 和 B;
  • git blame 将 John、Terry 和 Merry 列为 A 中各行的作者;
  • git blame 将 Jane 和 Mike 列为 B 中各行的作者;
  • 该命令将文件 A 和 B 作为输入文件,并返回 Jane、John、Terry、Merry 和 Mike。

所以我的想法是这样的:

  • 我在一个分支上完成了我的工作;
  • 执行命令,该命令将与 master 相比在此分支上修改的所有文件作为输入,并返回这些文件中行的所有作者的列表。

我们的想法是知道要对评论执行 ping 操作。

【问题讨论】:

标签: git git-blame


【解决方案1】:

您可以使用log,然后通过管道传送到sort

git log --all --pretty=format:"%an" -- path/to/fileA path/to/fileB | sort -u

如果你想要一个别名,去吧

git config --global alias.who '!f() { git log --all --pretty=format:"%aN" -- $1 | sort -u; }; f'

# then just
git who "path/to/fileA path/to/fileB"

【讨论】:

    【解决方案2】:

    列出路径为$path的文件中所有行的作者。

    git blame --porcelain -- $path | sed -n -e '/^author /s/^author //p' | uniq -u
    

    处理一组文件,比如A和B,

    for path in A B;do
        git blame --porcelain -- $path
    done | sed -n -e '/^author /s/^author //p' | uniq -u
    

    【讨论】:

      猜你喜欢
      • 2017-05-07
      • 2014-09-08
      • 2015-10-22
      • 1970-01-01
      • 2016-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多