【问题标题】:Get snapshot of a git repo on a particular date获取特定日期的 git repo 快照
【发布时间】:2013-09-26 13:51:52
【问题描述】:

假设我有一个包含多个银行的回购。

是否可以使用通常的 git foo 获取某个特定日期/时间的 repo 快照? (我们目前每天都有代码转储,我正在考虑删除它的方法)

(假设没有永久删除分支,并且没有玩过 git commit 历史)

编辑:临时分支合并是可能的。

【问题讨论】:

    标签: git git-log git-checkout


    【解决方案1】:

    注意@{<date>},基于 reflog(意思是,默认限制为 90 天)。
    请参阅git rev-parse 中的“Specifying Revisions”。

    "git checkout by date" 建议另一种方法:

    git checkout `git rev-list -n 1 --before="2013-09-25 5:00" master`
    

    注意this warning though

    如果您合并了任何分支,rev-list 将不起作用。
    例如:我想回到V5 分支,但最终进入了V4.2 分支。

    一种更强大的方法是添加--first-parent

    git checkout `git rev-list -n 1 --first-parent --before="2013-09-25 5:00" master`
    

    【讨论】:

      猜你喜欢
      • 2021-12-16
      • 2020-10-01
      • 2015-01-10
      • 1970-01-01
      • 2010-10-11
      • 2015-03-29
      • 2018-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多