Interactive Rebase of merged branch

An explicit way of making a feature branch feature into a new branch feature-one-commit with a single commit:

git checkout -b feature-one-commit \
"$(git commit-tree HEAD^{tree} -m "Commit message" -p master)"    

git rebase --interactive --preserve-merges

If the merge conflicts are identical, this is a perfect use case for git rerere, one of the most useful (albeit lesser-known) commands in git. From the man pages:

In a workflow employing relatively long lived topic branches, the developer sometimes needs to resolve the same conflicts over and over again until the topic branches are done (either merged to the "release" branch, or sent out and accepted upstream).

This command assists the developer in this process by recording conflicted automerge results and corresponding hand resolve results on the initial manual merge, and applying previously recorded hand resolutions to their corresponding automerge results.

git rerere keeps a record of your conflict resolutions and applies them automatically when encountering the same conflict in git merge, git rebase, or git commit (when committing a merge). Scott Chacon posted some great examples here, and the man page is also worth a read.

You can enable git rerere in merge and rebase by issuing this command:

git config --global rerere.enabled true

Remove the --global flag if you'd like the option enabled for just a single repository.

Tags:

Git

Git Rebase