I committed and pushed some bad things. How do I force revert my local repo to HEAD~7, and re-commit so that HEAD is now at that version? Git docs confuse me.
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.
The nicest approach is to push another commit that reverts the unintended commits. See Jakub Narębski’s answer on how to do that.
If for some reason it’s worth the potential unfriendliness of pushing an update that isn’t a fast-forward (sensitive bits in the commits, for example), give these commands:
The first rewinds your current branch. This is a sharp tool, so be careful.
To stop you accidentally losing work, git won’t push your rewound branch. The
--forceoption disables this safety feature.