是否有一个 git 命令可以显示谁提交/编辑了哪些文件?
输出应该是这样的:
FileName AuthorName
fileA user1 user2
fileB user 3
fileC user1
最佳答案
我认为您无法通过单个 git 命令来实现这一目标。
在 sh
、bash
或 zsh
中,您可以执行以下操作:
git ls-files -z | xargs --null -L1 -I % sh -c "printf %' '; git annotate -p % | sed -nr '/^author /{s/^author (.*)/\1/;p}' | sort | uniq | awk '{printf (\$0 \" \")}END{print \"\"}'"
或者,更具可读性:创建一个脚本文件print_file_and_its_authors.sh
:
#!/bin/sh
printf $1' ' # Output filename without appending a line break.
# Output file authors and a line break:
git annotate -p $1 \
| sed -nr '/^author /{s/^author (.*)/\1/;p}' \
| sort | uniq \
| awk '{printf ($0 " ")}END{print ""}'
然后执行:
chmod u+x print_file_and_its_authors.sh
git ls-files -z | xargs --null -L1 ./print_file_and_its_authors.sh
关于git - 是否有一个 git 命令可以显示谁提交/编辑了哪些文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37232026/