开发者

How do I check out what was in my git repository N days ago?

I have to check out my source code from two days ago. Whenever I have to do this, I have to look up the syntax. It's not in the git-checkout page. I'd like to have a convenient Stack Overflow question to refer to so I don't have to look it up every time. If this has already been asked, please poin开发者_运维问答t me to the dupe. :)

How do I check out my source code in git from two (or N) days ago?


git checkout @{two.days.ago}


All of these work (because git is pretty smart):

git checkout @{yesterday}
git checkout @{2.days.ago}
git checkout @{'2 days ago'}
git checkout @{'5 minutes ago'}
git checkout @{'1 month 2 weeks 3 days 1 hour 1 second ago'}
git checkout any-branch-name@{'1 hour ago'}

As @Jakub Narębski noted in his comment, these are references to your local repository at that time. More info in the Specifying Revisions section of the git rev-parse docs here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜