Git rerere for Repeated Agent Branch Conflicts
Prepared and checked using AI. Sources are linked in the article.
If you keep resolving the same merge conflict while integrating agent branches, enable git rerere in the repository. It records a manual resolution and can reuse it when a corresponding conflict appears again. You still review the resulting file and stage it yourself. That makes rerere useful when several agents change the same area, or when you encounter a conflict during an early integration pass and again during the final merge.
What rerere remembers
Rerere stands for “reuse recorded resolution.” On the first conflict, Git saves the conflicted version of the file. After you resolve it, rerere saves your result. When a later conflict is applicable, rerere tries a three-way merge using the earlier conflict, your earlier resolution, and the new conflict. A clean result goes into the working tree.
This is more specific than choosing one branch’s whole file. Say two agent branches each change a routing table while the integration branch has changed it too. You may need both additions, a particular order, and an updated import. Resolve that combination once. If a later merge presents an applicable conflict, rerere can reproduce the resolution while preserving other changes that merge cleanly.
“Applicable” matters. A different conflict may need a new decision, and a mechanically reused resolution may be wrong for the current code. Treat rerere’s output as a proposed edit, especially when agents have independently changed behavior around the same lines.
Enable it where you integrate branches
From the repository where you perform merges, set the repository-local rerere.enabled and rerere.autoUpdate options:
git config --local rerere.enabled true
git config --local rerere.autoUpdate false
The first setting activates recording. The second keeps reused resolutions out of the index until you stage them. false is the default for rerere.autoUpdate; setting it explicitly makes the intended review step clear to anyone inspecting the repository configuration. If you want rerere in every repository you use, --global is available, but a local setting is easier to adopt for one integration workflow.
Enable it before the first conflict you want to remember. If the conflict was already resolved and committed while rerere was disabled, turning it on afterward cannot reconstruct that manual decision from the finished file. Resolve the next occurrence with rerere enabled so it has a resolution to reuse later.
Start merges with committed or otherwise safely set-aside local work. A merge can stop on conflicts, and git merge --abort may be unable to reconstruct pre-merge uncommitted changes in some cases. A clean integration worktree also makes the proposed resolution easier to inspect.
Record the first resolution
For example, suppose agent/api is a branch produced in another worktree and src/router.ts is the conflicting file. In your integration worktree, begin the merge:
git merge --no-rerere-autoupdate agent/api
The command-line flag keeps the index unstaged even if a local setting differs from the one above. If the merge stops, use git status to identify the unmerged paths, and ask rerere which conflicts it is tracking:
git status
git rerere status
Open each conflicted file. Remove the conflict markers, combine the changes you actually want, and inspect the surrounding code. For an agent branch, check that the result still matches the task you meant to integrate; a syntactically tidy resolution can still discard a needed condition or import.
While editing, git rerere diff shows how your current resolution differs from the recorded conflicted version. Once the file contains your intended result, run rerere explicitly to record it, then inspect the merge diff:
git rerere diff
git rerere
git diff
git diff can show the conflict and the changes made toward its resolution. Review every conflicted path, not just the one in the example. Run the relevant project checks for the affected code, stage the resolved files, and finish the merge:
git add src/router.ts
git merge --continue
Git also invokes rerere during the normal merge and commit flow, so the explicit git rerere call is a useful checkpoint rather than a required extra command in every merge. You can inspect a recorded resolution before completing integration; recording it does not mean you must accept that merge result.
Reuse it on the next conflict
On a later merge, use the same review-friendly flag:
git merge --no-rerere-autoupdate agent/ui
git rerere remaining
git diff
Here agent/ui is another example branch. If it produces an applicable conflict, rerere writes its proposed resolution into the working tree. git rerere remaining lists conflicts it has not resolved, including conflict types it cannot track. An empty result is a useful signal, but it is not proof that the merged code is correct.
Inspect the resulting file, compare it with both branches’ intent, and run appropriate checks. If the reused edit needs adjustment, edit it before staging. Then stage every resolved path and continue:
git add src/router.ts
git merge --continue
Rerere leaves the index alone when auto-update is off. That pause is valuable: it gives you a visible point to approve the proposed resolution. If you set rerere.autoUpdate true, a cleanly reused resolution can be staged automatically; that saves a command but removes this particular review checkpoint. You can also use --no-rerere-autoupdate on an individual merge to keep the checkpoint.
What changes with multiple worktrees
Linked Git worktrees have separate working files and per-worktree state, while repository configuration is shared by default. Git’s rr-cache is a common-directory path shared among those worktrees. Thus, a resolution recorded in one worktree of a repository can be available when a comparable conflict appears in another worktree of that same repository.
That does not make the worktrees’ in-progress merges shared. Resolve and review the conflict in the worktree where you started that merge. If you need to locate Git’s metadata without assuming that a linked worktree contains a .git directory, git rev-parse --git-common-dir shows the common directory. Separate clones have separate repository data, so enabling rerere in one clone does not, by itself, supply its recorded resolutions to another.
This distinction helps when planning agent work. Let agents keep their own working files and branches, then integrate in a dedicated worktree. If two integrations encounter the same applicable conflict, the shared rerere cache can spare you the repeated edit; each merge still gets its own review and commit.
When a recorded answer needs correction
A reused resolution is tied to the conflict Git can recognize, not to your current requirements. Review it carefully after a refactor, a changed API contract, or a branch that adds a new case near the conflict. A successful replay only establishes that Git could apply the recorded edit cleanly.
If the reused result is wrong for the current conflict, keep the merge in progress, run git rerere forget src/router.ts, and resolve that file again. forget removes the recorded resolution for the current matching conflict so rerere can learn the corrected result. Edit the file, run git rerere, review the diff, and stage it only when satisfied. Use the path that is actually conflicted in your merge.
If nothing is reused, inspect git rerere status and git rerere remaining. The later conflict may differ enough that the old resolution is inapplicable. Rerere also relies on recognizable conflict markers in files, and some conflict types, such as conflicting submodules, cannot be tracked by it. Resolve those manually. Once you record a new resolution, a future applicable occurrence may benefit.
Rerere can also help when you rebase a branch and encounter an applicable conflict, but review is especially important there: rebase replays commits one at a time, so the surrounding code can differ from a single merge. Decide whether to merge or rebase based on the history you want, then use rerere to reduce repeated conflict editing within that workflow.
Where Parallel Code fits
Parallel Code is our free, open-source desktop app for macOS and Linux. It runs several AI coding agents in parallel, each isolated in its own Git worktree, and provides a diff-first review surface. Rerere remains a Git integration tool: use it as you merge the branches and review any reused conflict resolution before committing.
Frequently asked questions
Does rerere resolve every conflict automatically?
No. It reuses a recorded resolution only when it is applicable to the new conflict, and some conflicts cannot be tracked. Check git rerere remaining, resolve anything left by hand, and review every reused result before staging.
Should I turn on rerere.autoUpdate?
For agent branch integration, start with false so the reused file remains unstaged until you inspect it. If you later prefer automatic staging, you can enable it and still use git merge --no-rerere-autoupdate when a particular merge needs a manual checkpoint.
Will a resolution follow me into a different clone?
No automatic transfer is implied by enabling rerere: its cache belongs to the repository data used by the worktrees. Linked worktrees of one repository share that cache; a separate clone has its own repository data.
Can rerere replace code review or tests?
No. It remembers how a conflict was resolved, not why that result was correct. Review the final diff and run the checks relevant to the affected code before completing the merge.