As I understood, it is useful for the synchronization of projects through the saving of conflict resolution information, but it is not entirely clear to me how to use and configure it.
I want to configure for my continuous integration (CI) environment. Is it recommended do this?
Please don't mark a duplicate with this other question: Are there any downsides to enabling git rerere?. Because my doubt isn't related to "So is there any downside to enabling rerere?. What potential problems can it cause that would not otherwise occur?"
What is
git rerere?As the documentation notes,
rererestands for reuse recorded resolution.That doesn't really explain what it is, though. It's worth adding first, here, that
git rerereitself—the command—is not something you have to run. It has just six subcommands:clear,forget,diff,status,remaining, andgc. None of these record or reuse a resolution—in fact,git rerere clearandgit rerere forget <path>just discard some recorded resolutions. Thegccommand is similar, but refers to ones that are old, rather than current ones.Most of the work happens from the setting of
rerere.enabled(which makes Git rungit rerere, with no subcommand, for you, at the appropriate times). You can rungit rererewith no subcommands yourself, but this doesn't really do anything important since Git will do that on its own.git config rerere.enabled trueOnce you have set
rerere.enabled, when Git does a merge—any merge, including those fromgit amandgit rebaseandgit cherry-pickand so on, not just those fromgit mergeitself—and hits a conflict, Git will:git committime) what you did to resolve them.There's a step missing here, which is why this is numbered starting at 2. Step 1 is:
If the recorded resolutions completely resolve the conflicts, steps 2-4 become redundant. Git may still run them all (I'm not sure that it does) to update the timestamps on the recorded resolutions.
Summary
Once you set
rerere.enabled, it's the act of merging itself that both creates the conflicts and (because it automatically runsgit rererewith no arguments) records them and then tries to re-use any existing recorded resolutions. It's the act of committing itself that records the final resolutions (because Git automatically runsgit rerereagain for you). So it is all automatic—you just need to make sure, by running your owngit diffcommands, that your previous re-used resolutions are correct. If not, just fix them files, add, and commit as usual, and Git will replace the recorded resolutions with the new ones.Note that you must still
git addandgit commit! You should always inspect the merge results (and/or run tests)—though you should do this always, regardless of yourrerere.enabledsetting.As VonC points out in a comment, if you have existing merge conflict resolutions you did not record earlier, you can "train" the rerere database on those resolutions. There is a contributed script in the Git source to do this; it's also available on-line.