The goal
I want to modify a recent commit, using rebase. The magic command is git rebase -i
Let's say you're trying to delete the commit-in-question
- First, find out how far back that commit is (approximately). Then do:
- git rebase -i HEAD~10
-Source:
Greg Hewgill's answer to a less complicated git question
The problem
That works wonderfully, unless you've recently done any --no-ff merges
If you happen to follow git flow, you do --no-ff merges all the time
- Check the "Sources" section below for examples on the how & why of rebase -i blowing up --no-ff merges
- For now, just trust me (or try it yourself): It aint pretty
The actual question
If we look at this page we see a --preserve-merges
(or simply -p
) option that we can try replacing -i
with
The problem is, if we do that, we're no longer given that nice -i
pop-up from before
-> The one with choices for "edit this commit, sqaush that one", etc.
--> And so, we can't meet our original goal: modify/delete some recent commit using rebase :(
So, what do we do?
Sources
Problem section:
- First example of rebase murdering --no-ff commits
- Second example
- His quote: "The TL;DR version is this: When rebasing, always use the -p flag"