Resolving Merge Conflicts
When facing an in-progress git merge or rebase with conflicts:
See the current state. Check
git status,git log --oneline --merge, and the conflicting files withgit diff --diff-filter=U.Find the primary sources for each conflict. Understand why each change was made and its original intent. Read commit messages, check related PRs (use
gh-cliskill), and trace back to issues/tickets.Resolve each hunk. Preserve both intents where possible. Where incompatible, pick the one matching the merge's stated goal and note the trade-off. Never invent new behavior — you are resolving, not refactoring. Always resolve; never
git merge --abortorgit rebase --abort.Run automated checks. Discover the project's verification commands from
package.jsonscripts,Makefile, orAGENTS.md. Run typecheck, tests, then format. Fix anything the merge broke.Finish. Stage the resolved files by explicit path (
git add <path1> <path2>, orgit add -ufor tracked files only — nevergit add .orgit add <dir>, per AGENTS.md Git Safety), commit (git commitwithout-m— review the auto-generated merge message), or if rebasing,git rebase --continueuntil all commits are rebased.
Rules
- Conflict resolution is archaeology: understand the intent behind each side before touching code.
- Do not use
--abortto escape — it discards both sides' work. - If the same conflict pattern appears across multiple files, resolve them consistently.
- After resolution, the build must pass. If tests fail, the resolution broke something.