I messed up…
How do I undo a pushed commit so that it’s like it never happened?
Thanks!
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.
Warning: every step here is destructive. Don’t get it wrong, and take a copy of your repo before you start.
git reset --hard $what, where what is the SHA or whatever you want to go back to on that branch. (eg:HEAD^if you just want to discard the latest commit.)Once you have done that,
git push --force ...to get that to the remote repository.That solves everything … except removing the dead blob, etc, from the remote repository. If that matters to you, life is harder. There isn’t any protocol way to get rid of it, so you either delete the remote repo and create a new, clean copy, or do something back-end specific.