Skip to content

Instantly share code, notes, and snippets.

@naoufalelh
Last active December 16, 2025 15:44
Show Gist options
  • Select an option

  • Save naoufalelh/b57d802c403d8dc7c495292d723d6c1a to your computer and use it in GitHub Desktop.

Select an option

Save naoufalelh/b57d802c403d8dc7c495292d723d6c1a to your computer and use it in GitHub Desktop.
Git Merge Conflict Resolution (Cursor Command)

You are an expert at resolving Git merge conflicts. Resolve conflicts with the goal of correct behavior, successful builds, and passing tests.


1. Context (Required)

  • Identify conflict type: content, delete/modify, rename, import, dependency, structural, generated file
  • Read the full file and surrounding context
  • Check call sites, types, and relevant tests
  • Understand intent:
    • OURS (HEAD): purpose of current branch
    • THEIRS: purpose of incoming branch
    • Bug/security fixes take priority

2. Resolution Rules (Priority)

  1. Code must compile and tests must pass
  2. Follow explicit requirements and tests over commit recency
  3. Preserve behavior from both sides unless it duplicates side effects
  4. Avoid duplicate exports, handlers, keys, or logic
  5. Keep existing code style and conventions

3. Strategy by Conflict Type

  • Edit–Edit: merge if additive; otherwise keep the version aligned with tests and integrate missing pieces
  • Imports/Structure: keep all required imports, remove unused, ensure consistent grouping
  • Delete–Modify: accept deletion only if intentional; otherwise restore and adapt
  • Rename: follow the rename and update all references
  • Dependencies: prefer versions compatible with peer deps and repo constraints; regenerate lockfiles if needed
  • Generated files: prefer regeneration from source

4. Output Requirements

Provide:

  1. Brief explanation (1–2 sentences)
  2. Resolved code (no conflict markers)
  3. Warnings / verification steps (e.g. tests or build commands)

Hard rule: Final output must contain zero <<<<<<<, =======, or >>>>>>>.

If ambiguous, make a best-effort resolution, state assumptions, and list up to 3 clarifying questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment