如何显示 Git 存储库中特定作者更改的文件列表?
How to show changed file list by a specific author in a Git repository?
如何在 Git 存储库中显示特定作者更改的文件?
当我使用这个命令时git log --numstat --pretty=tformat:'%an'
,
git bash 将按作者对文件进行分组,如下所示:
WoJiaoChaDi-YSS
16 6 AHKScriptManager/scripts/AutoInput/HotKeyString.ini
1 1 AHKScriptManager/scripts/RemindMe/RemindConfig.ini
21 0 OneQuick.Ext.ahk
WoJiaoChaDi-PC
1 1 AHKScriptManager/scripts/AutoCapture/config.ini
但我想得到这样的结果:(作者在每个行头位置)
WoJiaoChaDi-YSS 16 6 AHKScriptManager/scripts/AutoInput/HotKeyString.ini
WoJiaoChaDi-YSS 1 1 AHKScriptManager/scripts/RemindMe/RemindConfig.ini
WoJiaoChaDi-YSS 21 0 OneQuick.Ext.ahk
WoJiaoChaDi-PC 1 1 AHKScriptManager/scripts/AutoCapture/config.ini
所以,谁能帮帮我?
可以通过一些 bash 脚本来完成:
#!/bin/bash
git log --pretty=tformat:'%H;%an' | while IFS=';' read COMMIT AUTHOR; do
git log --max-count=1 --numstat --pretty=tformat:'' "$COMMIT" | sed "s/^\(.\)/$AUTHOR\t/"
printf "\n"
done
感谢user14967413兄提供本题思路
我还有其他方法可以做到这一点,例如:
git log --numstat --pretty=format:'%an' | awk '{x=[=10=];tmp="";
if(tmp!~/^[0-9]+$/ && tmp!~/\-\-/){
name=[=10=]
} else {
OFS="\t"
print name, [=10=]
}
}'
学习了2个小时的awk语法是个收获
如何在 Git 存储库中显示特定作者更改的文件?
当我使用这个命令时git log --numstat --pretty=tformat:'%an'
,
git bash 将按作者对文件进行分组,如下所示:
WoJiaoChaDi-YSS
16 6 AHKScriptManager/scripts/AutoInput/HotKeyString.ini
1 1 AHKScriptManager/scripts/RemindMe/RemindConfig.ini
21 0 OneQuick.Ext.ahk
WoJiaoChaDi-PC
1 1 AHKScriptManager/scripts/AutoCapture/config.ini
但我想得到这样的结果:(作者在每个行头位置)
WoJiaoChaDi-YSS 16 6 AHKScriptManager/scripts/AutoInput/HotKeyString.ini
WoJiaoChaDi-YSS 1 1 AHKScriptManager/scripts/RemindMe/RemindConfig.ini
WoJiaoChaDi-YSS 21 0 OneQuick.Ext.ahk
WoJiaoChaDi-PC 1 1 AHKScriptManager/scripts/AutoCapture/config.ini
所以,谁能帮帮我?
可以通过一些 bash 脚本来完成:
#!/bin/bash
git log --pretty=tformat:'%H;%an' | while IFS=';' read COMMIT AUTHOR; do
git log --max-count=1 --numstat --pretty=tformat:'' "$COMMIT" | sed "s/^\(.\)/$AUTHOR\t/"
printf "\n"
done
感谢user14967413兄提供本题思路
我还有其他方法可以做到这一点,例如:
git log --numstat --pretty=format:'%an' | awk '{x=[=10=];tmp="";
if(tmp!~/^[0-9]+$/ && tmp!~/\-\-/){
name=[=10=]
} else {
OFS="\t"
print name, [=10=]
}
}'
学习了2个小时的awk语法是个收获