公开提交被推送到存储库的日期 [英] expose the date a commit was pushed to a repository

查看:185
本文介绍了公开提交被推送到存储库的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来查看提交被推送到远程存储库的日期。使用git log你可以看到作者日期和提交日期;然而,这些日期都没有告诉你开发人员何时实际上将变更推送到主远程存储库。

起初我以为我在寻找的东西根本就没有在git中可用,但是昨天我发现在log命令中指定日期范围实际上过滤了提交当天他们被推到主要的远程回购。下面是一个例子:假设我在2010年7月1日为本地主分支创作并提交了一个补丁。但现在现在是7月28日,我终于开始向远程主数据仓库推进了。然后我做一个'Fetch'来确保我的本地origin / master与远程主数据库的最新版本保持一致。

  • 我通过运行查看origin / master的日志:

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

    这些日志的结果表明,这是在2010年7月1日创作并提交的,尽管它只是推送到远程回购。


  • 所以我指定了一个日期范围(since..until)

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

    令我惊讶的是,git知道这是在过去一小时内被推送到远程存储库的,尽管它是在几周前创作并提交的。


  • 所以看起来git保留了提交到回购库的日期,我的问题是是否有任何方法公开该日期,所以我可以请参阅(例如)最近五次推送到远程存储库?



    <为了澄清,1小时前是指当您提取时,而不是当某人推送时

    如果core.logAllRefUpdates在裸回购中设置为true,则您可以cd到它,git reflog show branch回顾每次推送以及它包含的内容。

    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 date 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

    这篇关于公开提交被推送到存储库的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆