How to get Git log with short stat in one line?

后端 未结 7 1562
無奈伤痛
無奈伤痛 2020-12-09 15:52

Following command outputs following lines of text on console

git log --pretty=format:\"%h;%ai;%s\" --shortstat
ed6e0ab;2014-01-07 16:32:39 +0530;Foo
 3 files         


        
7条回答
  •  盖世英雄少女心
    2020-12-09 16:15

    combining all answers above, here are my 2 cents in case anyone is looking:

    echo "commit id,author,date,comment,changed files,lines added,lines deleted" > res.csv 
    git log --since='last year'  --date=local --all --pretty="%x40%h%x2C%an%x2C%ad%x2C%x22%s%x22%x2C" --shortstat | tr "\n" " " | tr "@" "\n" >> res.csv
    sed -i 's/ files changed//g' res.csv
    sed -i 's/ file changed//g' res.csv
    sed -i 's/ insertions(+)//g' res.csv
    sed -i 's/ insertion(+)//g' res.csv
    sed -i 's/ deletions(-)//g' res.csv
    sed -i 's/ deletion(-)//g' res.csv
    

    and either save it into git-logs-into-csv.sh file or just copy/paste into console.

    I think it's relatively self-explaining but just in case:

    • --all takes logs from all branches
    • --since limits the number of commits we want to look at
    • --shortstat - to get some idea what was done in the commit

提交回复
热议问题