Git:执行提交后,显示最后一次推送到每个远程的日期 [英] Git: after performing a commit, show the date of the last push to each remote
问题描述
我想要一个简单的git提交后操作,可以显示上次将更改推送到每个远程的日期。这个动机是一个简单的提示,说明你的回购可能会变得多么不同步,或者是一个很好的提醒,以备份你对远程裸回购的修改。
这存在,如果没有任何快速的建议,如何做到这一点?
如果它不存在,我最初的想法是:
- ,在.git / refs / remotes /中为每个远程分支做一个'git log [remote / branch]',并解析出日期信息。
欢迎任何关于这些步骤的开发策略的帮助(命令行linux是我的平台)
谢谢!
正如在git中有一种获取给定提交的推送日期的方法吗?,您需要为您的裸回购(您要推送到)来启用logAllRefUpdates
git config core.logAllRefUpdates true
然后你可以看看使用git reflog的日期
git reflog --date = local master
(但reflog时间有限,默认为90天)
通常使用 rev-parse
的其他方式(如如何获得最后一次push到git的ID?) ,更多关于SHA1的信息。
I want to have a simple git post-commit action that prints the date of the last time you pushed your changes to each remote. The motivation for this is a simple reminder of how far out of sync your repo may be becoming or a nice reminder to back up your changes to a remote bare repo.
Does this exist and if not any quick suggestions on how to do this?
If it doesn't exist, my initial thoughts would be:
- on post-commit, do a 'git log [remote/branch]' for each remote branch in the .git/refs/remotes/ and parse out the date information.
Any help on development strategies for these steps would be welcome (command line linux is my platform)
Thanks!
As mentioned in "Is there a way in git to obtain a push date for a given commit?", you need for your bare repo (to which you are pushing to) to enable logAllRefUpdates
git config core.logAllRefUpdates true
And then you can have a look at the dates with git reflog
git reflog --date=local master
(but reflog is time limited, 90 days per default)
Other ways usually with rev-parse
(as in "How do I get the ID of the last push in git?"), more about the SHA1.
这篇关于Git:执行提交后,显示最后一次推送到每个远程的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!