I commited something wrong twice. How to revert two commits back and commit only good stuff ?
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.
You can do a
git rebase -i HEAD~2and then use the interface to discard the “bad commits” that are there since then and clean up your history. This however alters the project history and if you’ve already pushed (and others pulled) your changes, there are some social issues to work out.The other option is to
git revertthose changes. Then 2 new commits will get added to the history that makes the fact that you don’t want these two commits explicit in the project history. Less clean but easier to work with.