Merge Conflict Resolution Checklist
A calm, repeatable process for resolving Git merge and rebase conflicts in Python repos - especially pyproject.toml, uv.lock, and Alembic migrations.
How to Use This Checklist
- Walk items in order during an active conflict - do not skip straight to editing markers.
- One file fully resolved and tested before moving to the next when conflicts are large.
- If more than 30 minutes stuck on one file, pause and pair - migrations and lockfiles benefit from a second reviewer.
- Record what caused the conflict in the PR description to prevent repeat collisions.
Phase 1 - Stabilize
- Confirm operation type: Know whether you are in
merge,rebase, orcherry-pick-git statusshows current state. - List conflicted files:
git diff --name-only --diff-filter=U- expectpyproject.toml,uv.lock,alembic/versions/*.py. - Abort if wrong branch:
git merge --abortorgit rebase --abortwhen you started on incorrect base. - Stash unrelated WIP:
git stash push -m "pre-conflict"if uncommitted edits mix with conflict resolution. - Fetch latest remote:
git fetch originso you resolve against currentmain, not stale local copy.
Phase 2 - Understand
- Read both sides: Open conflicted file -
<<<<<<<,=======,>>>>>>>mark yours vs incoming. - Check commit messages:
git log --oneline --left-right HEAD...MERGE_HEAD(merge) or incoming commits on rebase. - Identify semantic intent: Is conflict cosmetic (import order) or behavioral (dependency version, migration revision)?
- Lockfile rule: For
uv.lock/poetry.lock- pick winningpyproject.tomlside, delete conflict markers, runuv lock. - Migration rule: For Alembic - never duplicate revision ids; may need
alembic mergeheads after resolution.
Phase 3 - Resolve
- Resolve one file at a time: Remove all conflict markers; leave valid Python/TOML syntax.
- Prefer upstream dependency policy: When unsure on library version, align with
mainunless ticket requires bump. - Run formatter on touched Python:
uv run ruff formaton resolved.pyfiles. - Stage resolved file:
git add <file>only when markers fully removed -git diff --checkcatches leftovers. - Continue operation:
git rebase --continueor complete merge commit after all files staged.
Phase 4 - Verify
- Sync environment:
uv sync --frozenmust succeed after lock resolution. - Lint:
uv run ruff check . - Typecheck (if configured):
uv run mypy src/or pyright on affected packages. - Tests:
uv run pytest -q- minimum affected module tests if full suite is slow. - Migrations:
uv run alembic upgrade headon local DB when migration files conflicted.
Phase 5 - Finish
- Review diff size:
git diff origin/main...HEAD- ensure no accidental deletions of others' work. - Force push safely after rebase:
git push --force-with-leaseonly on your feature branch. - PR comment: Note conflict files and how you chose versions - helps reviewers focus.
- Follow up prevention: Split ticket or rebase more often if same files conflict repeatedly.
- Close loop with author: If incoming change was misunderstood, sync with original commit author before merging.
Applying the Checklist in Order
- Phase 1-2 (1-10): Understanding before editing prevents wrong-side merges that pass tests but break prod deps.
- Phase 3-4 (11-20): Verification gates catch lockfiles that parse but pin incompatible versions.
- Phase 5 (21-25): Communication reduces repeat conflicts on hot files like
pyproject.toml.
FAQs
Merge or abort a messy rebase?
If conflicts touch more than ~10 files unexpectedly, abort and try merge commit instead - or merge main once then resume smaller rebases.
IDE auto-resolve safe?
Use IDE 3-way merge for Python sources; never auto-resolve lockfiles or migrations.
Conflict only in __pycache__ or .venv?
Those should be gitignored - git rm --cached and fix .gitignore, do not commit artifacts.
Notebook JSON conflicts?
Prefer nbstripout pre-commit to prevent; see Git for Data/Notebooks.
Related
- Branching & Merging - when conflicts arise
- Essential Git Commands - abort/continue commands
- Dependency Resolution and Lockfiles - lock policy
- Alembic - migration merges
Stack versions: This page was written for Python 3.14.0 (stable 3.14, maintenance 3.13), FastAPI 0.115+, Django 5.2, Flask 3.1, Pydantic 2, PyTorch 2.6+, pandas 2.2+, Polars 1.x, ruff 0.9+, and uv 0.6+.