Suppose I have this feature branch “foo”. Now I want to merge it back into master, but I’ve added some debugging code that I don’t want in master.
The debug code is in it’s own commit, so I could use git cherry-pick on each commit and leave out this commit. But that’s gonna be quite tiresome.
Is there some “inverse cherry-pick” that does this, or an interactive merge?
Use interactive rebase:
That will open something like this in your $EDITOR:
So what you do is simply to remove the line containing the debug commit, write the file and close your editor, and git will tell you something along the lines of:
Now you can just merge in that branch to master.
UPDATE: It should be noted that altering history with
rebaseshould only happen on private branches. If this branch has been exposed to the public, usegit revertas proposed by other answerer.