Is there a way in git to obtain a push date for a given commit?

后端 未结 8 2017
眼角桃花
眼角桃花 2020-11-27 12:25

I am wondering if there is a way to view a push date associated with each commit in the git log. If that is not possible, is there a way to see all the commits under a cert

8条回答
  •  野性不改
    2020-11-27 12:37

    git reflog show origin/master --pretty='%h %gd %gs %s' --date=iso
    

    This seems to work pretty well for me. The committer date (%cd) is misleading because it's not necessarily the same as push date. The --date=iso option, however will output the push/fetch date.

    Note, if you fetched from origin/master, it will print the date you fetched it; NOT the date someone else pushed the commit.

     - %h:  abrev. hash
     - %gd: human readable reflog selector
     - %gs: reflog subject
     - %s:  subject/commit message
    

    Bonus: You can of course, do more pretty formatting. So far, I like this color coding. It's a bit much to type though. This will output the SHA to red, reflog selector to cyan, and reflog subject to green.

    git reflog show origin/master --pretty='format:%C(red)%h%Creset %C(cyan)%gd%Creset %C(green)%gs%Creset: %s' --date=iso
    

提交回复
热议问题