| 38 | Erasing Commits |
You can tell Git to erase commits. This is contradictory to most version control systems, but you can treat any commit that you haven’t already shared with the rest of the world as something that can be adjusted as necessary.
A word of caution before we get into specifics, though. Don’t
delete commits that you’ve shared without a very good reason.
Deleting commits causes the history to be rewritten, causing the
ripple effect problems like a git
rebase. If you’ve shared commits, your best bet
is git revert (see Task 36, Reverting Commits).
You can use git rebase a couple of
different ways to handle deletes. First, you can add the
-i parameter to go into an interactive rebase. Once launched, delete the line (or lines) ...