So I wanted to go back to my previous commit without destryoing the latest one I have now. How do I do this? Doing a git reset HARD will destroy my current commit right?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you don’t have any changes that you have not checked in,
git checkout $OLD_COMMITwill take you there, andgit checkout $BRANCHwill take you back.That will put you, potentially, on a detached head; see
git checkout --helpfor the details, but if all you want is to run tests on the old version or something that should be fine.You might also be interested in:
git stash– to store away uncommitted changes temporarilygit show $SHA1to show the changes of the old commit as a diffgit show ${REF}:${PATH}to show the content of $PATH in $REF(Ref can be a sha, or a branch, or whatever, in the last git show invocation.)