是否有git命令显示谁提交/编辑了哪些文件? [英] Is there a git command to show what files are commited/edited by who?

查看:130
本文介绍了是否有git命令显示谁提交/编辑了哪些文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个git命令显示谁提交/编辑了哪些文件?

Is there a git command to show what files are commited/edited by who ?

输出应类似于:

FileName AuthorName

fileA user1 user2 
fileB user 3 
fileC user1

推荐答案

我认为您无法通过单个git命令来实现这一目标.

I don't think you can achieve this with a single git command.

shbashzsh中,您可以执行以下操作:

In sh, bash, or zsh you can do this:

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:

Or, more readable: Create a script file 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命令显示谁提交/编辑了哪些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆