How to prevent lot of git conflicts when git rebasing lot of commits?

Fortunately, git has a mechanism for dealing with exactly this problem called git rerere - essentially, if you have git rerere enabled, then each time your resolve a conflict the fact that you resolved that exact conflict in a particular way is remembered. If the same conflict comes up again, the same resolution is automatically used. There are some helpful articles below:

  • http://scottchacon.com/2010/03/08/rerere.html (blog post)
  • http://git-scm.com/docs/git-rerere.html (manual entry)
  • Are there any downsides to enabling git rerere? (question in stackoverflow)
  • http://progit.org/2010/03/08/rerere.html (original answer link: seems broken)

... but essentially you can just do:

git config --global rerere.enabled 1

... and forget about it, while enjoying easier rebasing / merging :)


Make sure that you are always rebasing using the --onto switch.

To prevent conflicts, use floating development branches. Each developer will continuously rebase their development branch. This is easy since the developer knows what he just implemented and shouldn't have problem with solving conflicts. Instead of rebasing, just merge the final version (it will already be rebased).