开发者

expose the date a commit was pushed to a repository

I'm looking for a way to see the date a commit was pushed to a remote repository. Using git log you can see both the author date and the commit date; however, neither of these dates tell you when the developer actually got around to pushing the change up to the main remote repository.

At first I thought what I was looking for was simply not available in git, but then yesterday I discovered that specifying a date range in the log command actually filtered the commits by the day they were pushed to the main remote repo. Here is an example:

  1. Let's say I authored and committed a patch to my local master branch on July 1st 2010. But now it is July 28th and I finally get around to doing a push up to the remote master repo.

  2. Then I do a 'Fetch' to ensure that my local origin/master is up to date with the remote master repo.

  3. I look at the log for origin/master by running:

    git log --format="format:%H %nAuthor Date: %ad %nCommit Date: %cd %n" origin/master
    

    The results of the logs show that this was authored and committed on July 1st 2010 even though it was just pushed to the remote repo.

  4. So I specify a date range (since..until)

    git log --format="format:%H %nAuthor Date: %ad %nCommit Date: %cd %n" origin/master@{"1 hour ago"}..origin/master
    

    and to my amazement git knows that this was pushed to the remote repository within the past hour even though it was authored and committed weeks ago.

So it seems that git retains the da开发者_高级运维te that commits are pushed to a repo, my question is whether there is any way to expose that date so I can see (for example) the five most recent pushes to the remote repository?


Unfortunately, the @{"1 hour ago"} syntax checks the reflog of the branch in question (in this case, origin/master). This reflog is unique to each clone, and is not pushed, pulled, or cloned. On top of that, the default value for core.logAllRefUpdates for bare repositories is false, so a typical "server" won't have the reflogs which would provide you this information.

To clarify, the "1 hour ago" refers to when you fetched, not when someone pushed

If core.logAllRefUpdates was set to true in the bare repo, you could cd to it and "git reflog show branch" to look back at each push and what it contained

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜