Setting up a git repository with some messy commits. Everything is working and all good, but I would like to remove/delete the messy commits – how do you go about doing that?
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.
If you want to go through the entire history, I think the best way would be an interactive rebase
git checkout mastergit tag oldmastergit branch newbranch sha1ofRootCommitgit rebase -i newbranchYour editor should pop up. Delete the lines of the commits you don’t want. If everything goes well and there were no conflicts,
mastershould contain your clean history.Here is a link to a similar question
As CharlesB said you can squash commits into a single one if you still want to keep the changes by replacing
pickwithsquashinstead of deleting the line.