Reputation: 12617
I have for example 10 commits. I want to delete fifth commit forever. How do I delete only fifth commit.
Upvotes: 1
Views: 115
Reputation: 4072
Say your commit has SHA1 abc123
, you can do for example:
git rebase -i abc123^
delete the first line, save and quit. This will replay the whole history since that commit, so it can create conflicts, which you'll need to resolve by hand.
Upvotes: 5
Reputation: 11731
git rebase -i HEAD~5
In the text editor that comes up delete the rogue commit, then save and exit.
You may find a guide to interactive rebase helpful
Upvotes: 4