Home Explore Blog CI



git

1st chunk of `Documentation/git-rerere.adoc`
3c659b96db84b531e43c9737b3ba953890f9183ee92d70b60000000100000f34
git-rerere(1)
=============

NAME
----
git-rerere - Reuse recorded resolution of conflicted merges

SYNOPSIS
--------
[verse]
'git rerere' [clear | forget <pathspec>... | diff | status | remaining | gc]

DESCRIPTION
-----------

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.

[NOTE]
You need to set the configuration variable `rerere.enabled` in order to
enable this command.


COMMANDS
--------

Normally, 'git rerere' is run without arguments or user-intervention.
However, it has several commands that allow it to interact with
its working state.

'clear'::

Reset the metadata used by rerere if a merge resolution is to be
aborted.  Calling 'git am [--skip|--abort]' or 'git rebase [--skip|--abort]'
will automatically invoke this command.

'forget' <pathspec>::

Reset the conflict resolutions which rerere has recorded for the current
conflict in <pathspec>.

'diff'::

Display diffs for the current state of the resolution.  It is
useful for tracking what has changed while the user is resolving
conflicts.  Additional arguments are passed directly to the system
'diff' command installed in PATH.

'status'::

Print paths with conflicts whose merge resolution rerere will record.

'remaining'::

Print paths with conflicts that have not been autoresolved by rerere.
This includes paths whose resolutions cannot be tracked by rerere,
such as conflicting submodules.

'gc'::

Prune records of conflicted merges that
occurred a long time ago.  By default, unresolved conflicts older
than 15 days and resolved conflicts older than 60
days are pruned.  These defaults are controlled via the
`gc.rerereUnresolved` and `gc.rerereResolved` configuration
variables respectively.


DISCUSSION
----------

When your topic branch modifies an overlapping area that your
master branch (or upstream) touched since your topic branch
forked from it, you may want to test it with the latest master,
even before your topic branch is ready to be pushed upstream:

------------
              o---*---o topic
             /
    o---o---o---*---o---o master
------------

For such a test, you need to merge master and topic somehow.
One way to do it is to pull master into the topic branch:

------------
	$ git switch topic
	$ git merge master

              o---*---o---+ topic
             /           /
    o---o---o---*---o---o master
------------

The commits marked with `*` touch the same area in the same
file; you need to resolve the conflicts when creating the commit
marked with `+`.  Then you can test the result to make sure your
work-in-progress still works with what is in the latest master.

After this test merge, there are two ways to continue your work
on the topic.  The easiest is to build on top of the test merge
commit `+`, and when your work in the topic branch is finally
ready, pull the topic branch into master, and/or ask the
upstream to pull from you.  By that time, however, the master or
the upstream might have been advanced since the test merge `+`,
in which case the final commit graph would look like this:

------------
	$ git switch topic
	$ git merge master
	$ ... work on both topic and master branches
	$ git switch master
	$ git merge topic

              o---*---o---+---o---o topic
             /           /         \
    o---o---o---*---o---o---o---o---+ master
------------

When your topic branch is long-lived, however, your topic branch
would end up having many such "Merge from master" commits on

Title: Git Rerere: Reusing Recorded Conflict Resolutions
Summary
The git-rerere command assists in reusing recorded resolutions of conflicted merges, allowing developers to avoid resolving the same conflicts multiple times in long-lived topic branches, and provides various subcommands to manage and interact with its working state.