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 point me to the dupe. :)
How do I check out my source code in git from two (or N) days ago?
Git file History provides information about the commit history associated with a file. To use it: Go to your project's Repository > Files. In the upper right corner, select History.
Use the git status command, to check the current state of the repository.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With