Is there a nice way to change my Git working copy to something a given number of commits ago.
E.g. To see 3 commits into the past, something like:
git reset HEAD - 3
The use case here is that I just want to see if the tests that are failing in the current working copy were also failing before my latest commit. I don't necessarily want to make any changes to the previous versions. I would then want to change the working copy back to the latest commit.
If you simply want to look at a previous commit (without altering the state of your branch/repository), use git checkout
.
git checkout HEAD~3
If you decide you want to do development off of this point, you can then branch.
git checkout -b specialFeature47
To return to the present, simply checkout the branch name you were on.
git checkout master
Be weary of the suggested git reset
solutions. Those actually move your branch pointer (effectively deleting those 3 commits).
Yes, that's possible:
git reset --hard HEAD~3
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