Issue
I am trying to checkout and old version of my code from the master
branch and I am doing as follow:
git checkout -b master_de1974 `git rev-list -n 1 --before="5 days ago" master`
Is that the right command? How I can be sure if I am getting the old code instead the new one?
Solution
You should refer to a specific commit to be sure you are at the exact “position”, version of your code you expect.
To find the commit number, you can check on github/bitbucket or whatever is your remote repository. If you have not “UI repository”, you can list your commit by using the git log
command, https://git-scm.com/docs/git-log, for example:
git log -n10
will display the 10 last commits that have been saved to the tree. Once you find your commit,you can create your new branch from here:
git checkout -b master_de1974 a9c146a09505837ec03b
Where a9c146a09505837ec03b is your commit number. Then you can be sure you are on the good date/commit, by typing again
git log -n1
It should show you the commit you choose to be back to.
Answered By – olibiaz
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0