2

I already how to reset hard the commits to the exact commit I want, but that is not what I am trying to do here.

I'm hoping to delete the 2 bad commits.

  • dfc736c
  • bd4150e

What is the proper way to do that ?

1

1 Answer 1

2

The task at hand seems pretty simple and can be daunting but here's the steps:

  1. First, go ahead and run the command git log --pretty=oneline --abbrev-commit which will print out a pretty log of your git commit history, find the ones you want to delete.

  2. Run the follow command, git rebase -i HEAD~X but replace X with the number of commits you want to fetch.

  3. This will open an editor with however many commits you specified, simply remove the lines with the commits you want to remove, this will wipe those commits.

  4. Save and close the file, rebase should go ahead and work its magic and remove those commits. If you want this to also update a remote origin, git push origin +master will update the origin on branch master.

Not the answer you're looking for? Browse other questions tagged or ask your own question.