How to make git log output that just shows date and hash on one line?

前端 未结 5 1741
时光说笑
时光说笑 2021-01-19 05:59

I need to get the Date and commit results of a set of github in this format:

Date Commit
19 Mar 2015 b6959eafe0df6031485509c539e22eaf2780919c
1 Apr 2015 9a         


        
5条回答
  •  误落风尘
    2021-01-19 06:30

    How about:

    git log | awk '/^commit / { commit = $2 }
                   /^Date: /  { printf "%s %s %s %s\n", $4, $3, $6, commit }'
    

    Capture the commit information in the variable commit. When a date comes along, print the date and commit information.

    It is often a bad idea to pipe the output of grep to awk; awk is perfectly capable of doing the filtering that grep does.

提交回复
热议问题