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

前端 未结 5 1610
时光说笑
时光说笑 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:29

    The "git log" command is powerful enough to handle this on its own. Play around with variations on this:

    git log --date=iso --pretty=format:"date={%ad}, commit={%H}"
    

    For me this outputs:

    date={2014-12-12 14:14:23 -0800}, commit={75390af8bcd42c4dde6d841dc53f66a9ca91f460}
    date={2014-12-09 18:53:32 -0800}, commit={8dcf9eb10611e6ac778e518cf37efb041c69f5b5}
    date={2014-12-11 17:17:26 -0800}, commit={c3c1120b6dda6b317e1de5c7fe4eed7c8741ea1a}
    

    To achieve the exact format you specified (though with the date formatted a bit more reasonably), try this:

     ​git log --date=short --pretty=format:"%ad %H"
    

    Which outputs things like:

    2015-08-18 1d0ca5a596f02958c4ba8ff269def3f235c64495
    2015-08-18 d92fc3ebb62d2ca3e24322db2b669fdaebde7ea1
    2015-08-18 6ba3970620e19699c2969b1eed5c479b07b8908a
    

提交回复
热议问题