简体   繁体   中英

How to show changed file list by a specific author in a Git repository?

How to show changed files by a specific author in a Git repository?

When I use this command git log --numstat --pretty=tformat:'%an' ,

git bash will group files by the author, like this:

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

but I want to get result like this: (author in every line head posistion)

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

so, who can help me?

Thanks for providing way for this question, user14967413 brother.

And I have an other way to do that, like this:

git log --numstat --pretty=format:'%an' | awk '{x=$0;tmp=$1""$2;
    if(tmp!~/^[0-9]+$/ && tmp!~/\-\-/){
        name=$0
    } else {
        OFS="\t"
        print name, $0
    }
}'

It is harvest that I have learned awk syntax for 2 hours.

It could be done with some bash scripting:

#!/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\1/"
  printf "\n"
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM