在特定日期获取git仓库的快照 [英] Get snapshot of a git repo on a particular date

查看:107
本文介绍了在特定日期获取git仓库的快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否有可能使用通常的git foo获取特定日期/时间的回购快照?
(我们目前每天都有代码转储,我正在考虑如何删除这些代码)



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



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

解决方案

根据reflog(意思是默认限制为90天),注意 @ {< date>}

请参阅指定修订 ://git-scm.com/docs/git-rev-parserel =nofollow noreferrer> git rev-parse



git checkout by date 提示另一种方法:

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

请注意这个警告虽然


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

更强大的方法是添加 - 第一父母

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


Say I have a repo with multiple banches.

Is it possible to get the repo snapshot of some particular date/time using usual git foo? (We currently have code dumps every day, and I am thinking of ways to remove that)

(Assuming no branches are permanently deleted, and the git commit history hasn't been played with)

Edit: Interim branch merges are possible.

解决方案

Beware of the @{<date>}, based on the reflog (meaning, limited by default to 90 days).
See "
Specifying Revisions" in git rev-parse.

"git checkout by date" suggests another method:

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

Note this warning though:

rev-list won't work if you have any branches merged.
For example: I wanted to go back on V5 branch but ended up in V4.2 branch.

A more robust way would to add --first-parent:

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

这篇关于在特定日期获取git仓库的快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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