I’m using git and I’m getting to this state:
X --- Y --------- M1 -------- M2 (my-feature)
/ / /
/ / /
a --- b --- c --- d --- e --- f (stable)
This happen when we work on ‘my-feature’ branch for more than a day.
M1 and M2 are merged done from the stable branch to the feature branch. M1 and M2 may had merged conflicts which have been resolved.
The whole idea of merging the stable branch into the feature branch is to handle the conflicts sooner rather than later.
Once the feature is complete we want to rebase the feature branch into one or two commits.
The problem is when we do interactive rebase git show us the same merge conflicts we already solve during M1 and M2 merges.
Is there way to make git reuse the merge decision we already done in M1 and M2 ?
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:git rererekeeps a record of your conflict resolutions and applies them automatically when encountering the same conflict ingit merge,git rebase, orgit 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 rerereinmergeandrebaseby issuing this command:Remove the
--globalflag if you’d like the option enabled for just a single repository.