A merge conflict means Git cannot safely combine changes automatically. It does not mean one side is necessarily correct. The goal is to understand the intent of both changes and produce a valid combined result.
Inspect the conflict context
Read the surrounding code and inspect the commits that introduced each side. Conflict markers identify competing text, but the correct resolution may require preserving parts of both versions or redesigning the affected logic.
Use git status to identify unresolved paths and inspect the base, ours, and theirs when the distinction is unclear.
Avoid blind acceptance
Commands that choose one side for every conflict can discard important behavior. Use them only when the intended outcome is known for the specific operation. Generated files may need to be regenerated rather than manually merged.
Verify behavior
After editing, remove all conflict markers, stage resolved files, and run focused tests plus broader checks where appropriate. Review the final diff against the target branch to ensure the resolution did not introduce unrelated changes.
Checklist
- Understand both changes before editing.
- Inspect the common base when intent is unclear.
- Avoid global “ours” or “theirs” shortcuts without review.
- Regenerate generated artifacts where appropriate.
- Test and inspect the complete result.