Get snapshot of a git repo on a particular date

霸气de小男生 提交于 2019-12-03 14:31:34
VonC

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`
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!