How can I verify a Git conflict resolution before completing a merge?
Quick answer
Before completing a merge, read each resolved file, check for leftover conflict-marker text, and run git status to confirm there are no unmerged paths. Stage the resolved file, then inspect git diff --cached to review what would be recorded. These checks reveal omissions and unintended edits, but they cannot prove that the code behaves correctly; use relevant project tests or review as appropriate.
The question, the details, the next step.
A practical checklist
Read each resolved section in context, including nearby lines.
Search edited files for leftover conflict-marker text and inspect any matches.
Run
git statusand confirm no paths remain unmerged.Stage the resolved path, then review
git diff --cachedfor unintended or missing changes.If using the default
ortstrategy, considergit diff AUTO_MERGEas an additional textual comparison.Run relevant project checks when available; do not treat clean status or a marker-free file as proof of correctness.
A few more useful answers
Does finding no conflict markers mean the resolution is correct?
No. It only means your search did not find the text you checked for. Read the resolved content and review the staged diff; neither check automatically proves semantic correctness.
What is the difference between `git diff` and `git diff --cached` here?
git diff shows working-tree changes that are not staged. git diff --cached shows the staged changes compared with HEAD—the content that would be committed. [S2]
Does `git diff AUTO_MERGE` apply to every merge?
The documented comparison is for reviewing textual conflict-resolution edits when using the default ort strategy. The documentation does not establish that it applies to every merge setup or verifies the resolution’s correctness. [S1]
Sources
References used for this guide.
- [S1] Git - git-merge Documentation git-scm.com · Checked
- [S2] Git - git-diff Documentation git-scm.com · Checked
