Gitprompt onlyMedium

Merge Conflict Resolver

Automate the resolution of Git merge conflicts by iteratively detecting conflicts, resolving them, and retrying the merge until successful.

← all loops
GitmergeconflictCLIautomationversion control

Goal

Automatically resolve merge conflicts in a Git repository by iteratively fixing conflicted files and re-attempting the merge until completion.

How to Run

Initiate the loop to automatically resolve Git merge conflicts through iterative detection and resolution.

  1. 01

    Start Merge Conflict Loop

    Run the kickoff prompt to begin detecting and resolving conflicts in the repository.

  2. 02

    Iterate Until Merge Success

    The loop will automatically check for merge conflicts, resolve them, and retry the merge command up to 10 times.

Workflow Steps

  1. 01

    Detect merge conflicts using 'git status' or 'git diff --check'

    Check if there are unresolved conflicts in the working directory.

  2. 02

    For each conflicted file, analyze the conflict markers and resolve the differences.

    Verify that conflict markers (<<<<<<<, =======, >>>>>>>) are removed and the code is syntactically valid.

  3. 03

    Stage the resolved files using 'git add <file>'

    Confirm the file is staged and marked as resolved in Git.

  4. 04

    Run 'git merge' to attempt to complete the merge process.

    Check if the merge command exits successfully and without remaining conflicts.

  5. 05

    If merge fails and iterations remain, repeat the workflow from step 1.

    Evaluate whether the exit condition has been met (merge succeeded).

Kickoff Prompt

Start the "Merge Conflict Resolver" loop.

Goal: Automatically resolve merge conflicts in a Git repository by iteratively fixing conflicted files and re-attempting the merge until completion.
Max iterations: 10
Between iterations run: git merge
Exit when: Merge completes successfully without conflicts


You are in a Git repository where a merge operation has encountered conflicts. Your task is to automatically detect and resolve these conflicts. Begin by running 'git status' to identify conflicted files. For each file with conflicts, carefully analyze the conflict markers and determine the correct merged code. After resolving, stage the files with 'git add', then retry the merge with 'git merge'. If the merge still reports conflicts, repeat the process until it succeeds or until you reach 10 iterations. Do not modify unrelated files or make changes outside the conflict resolution scope.

Self-pace this loop. After each iteration, run `git merge` and evaluate the output, and only continue if the exit condition is not met (Merge completes successfully without conflicts). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.

Guardrails

hardcoded
  • ·Do not modify files outside the scope of the merge conflict resolution.
  • ·Ensure that resolved conflicts do not break the integrity of the codebase.
  • ·Limit iterations to prevent infinite loops in persistent conflict scenarios.
  • ·Verify the merge result after each resolution to confirm progress.

Flow Diagram

rendering…

Related loops — Git