LinuxCommandLibrary

git-rerere

Reuse recorded resolution of conflicted merges

TLDR

Enable rerere globally

$ git config --global rerere.enabled true
copy

Forget a file's recorded resolution
$ git rerere forget [path/to/file]
copy

Check the status of recorded resolutions
$ git rerere status
copy

SYNOPSIS

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

PARAMETERS

clear
    Remove all recorded resolutions from the cache.

forget <pathspec>...
    Forget recorded resolutions for specified paths.

status
    List paths with recorded resolutions for current conflicts.

remaining
    List conflicted paths lacking recorded resolutions.

diff
    Show diff between conflicted and resolved versions (accepts diff options like -p, -R).

gc
    Prune records older than 30 days; use --auto for automatic cleanup if cache exceeds 50MB.

--help
    Display help message.

DESCRIPTION

In Git, git rerere ('reuse recorded resolution') automatically records manual resolutions to merge conflicts and re-applies them to identical conflicts in future merges or rebases. This saves time on repetitive conflicts, common in long-lived branches, topic branches, or maintainer workflows.

When enabled (git config rerere.enabled true), Git captures the conflicted <<< ===== >>> state and your resolved version after git add. On the same conflict later, it restores your resolution, marking files clean. It works with git merge, git rebase, git am, and cherry-pick.

The command manages the .git/rr-cache/ database: view status, clear records, forget paths, prune garbage, or diff resolutions vs. conflicts. Ideal for reducing manual work in complex histories, but requires enabling and occasional cleanup to avoid bloat.

CAVEATS

Records grow in .git/rr-cache/; run gc periodically. Does not auto-resolve non-identical conflicts. Enable via config first; disabled by default.

ENABLE GLOBALLY

git config --global rerere.enabled true
Activates automatic reuse on merges/rebases.

TYPICAL WORKFLOW

Resolve conflicts, git add files (records resolution), commit. Next identical conflict: auto-applied, no manual edit needed.

HISTORY

Rerere originated as a contrib script in Git 1.5.3 (2007). Integrated into core Git plumbing around 1.6.x; full git rerere command added in 1.7.3 (2009) for direct management.

SEE ALSO

Copied to clipboard