git-advanced-merging
Skill0 starsChanged 39 days agoMITView on GitHub
Use when resolving non-trivial merge conflicts, choosing a merge strategy, or undoing a merge — covers -X options, diff3 markers, strategy vs option, reset vs revert -m, and re-merging reverted branches
- Deletes or force-pushes
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- postgres-locking-joinsSkill
- ai-bug-patternsSkill
- compressed-ndjson-boundariesSkill
- http-resume-integritySkill
- linux-io-latency-triageSkill
- macos-disk-space-recoverySkill
- minimal-sufficient-evidenceSkill
- modularize-large-filesSkill
- patch-reproducer-validitySkill
- prompt-cache-boundariesSkill
- proton-drive-selective-backupSkill
- transactional-outbox-deliverySkill
- conventional-commitsSkill
- git-bisect-forensicsSkill
- git-data-recoverySkill
- git-hooksSkill
- git-rerereSkill
- git-reset-mechanicsSkill
- git-revisions-syntaxSkill
- git-rewriting-historySkill
- git-submodulesSkill
- git-worktreesSkill
- github-ssh-keysSkill
- npm-publish-ci-pitfallsSkill
- sapling-stacked-pr-workflowSkill
- go-concurrency-patternsSkill
- go-data-idiomsSkill
- go-error-handlingSkill
- go-interfaces-embeddingSkill
- go-pprof-profilingSkill
- marketing-funnel-diagnosisSkill
- marketing-geo-experimentsSkill
- marketing-incrementalitySkill
- marketing-positioning-testsSkill
- python-descriptors-mroSkill
- python-logging-cookbookSkill
- python-scaling-regression-testsSkill
- python-unicode-gotchasSkill
- rust-compile-time-invariantsSkill
- rust-deterministic-concurrency-testsSkill
- rust-error-identity-boundariesSkill
- rust-regex-search-contractsSkill
- rust-runtime-bug-classesSkill
- rust-tokio-actor-deliverySkill
- rust-tokio-cancellation-safetySkill
- sales-discovery-qualificationSkill
- sales-mutual-action-plansSkill
- sales-pipeline-forecast-calibrationSkill
- sales-value-negotiationSkill
- ai-triage-evaluationSkill
- container-image-patchingSkill
- dependency-artifact-integritySkill
- dnssec-sentinel-diagnosticsSkill
- iam-policy-change-replaySkill
- rbvm-applicabilitySkill
- rbvm-asset-evidenceSkill
- rbvm-guarded-remediationSkill
- rbvm-priority-decisionsSkill
- rbvm-risk-exceptionsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Default hides the common ancestor.
- Very specific: line 65
Gotcha: after revert -m 1, re-merging the same branch pulls only new commits — Git thinks the rest is already merged.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Advanced Git Merging
Conflict Marker Style
Default hides the common ancestor. Show it:
git config --global merge.conflictStyle zdiff3 # git 2.35+; else diff3
git checkout --conflict=diff3 path # re-render existing conflictMarkers become <<<ours / ||| base / === / theirs >>> — resolution is far easier.
Side-Picking
git checkout --ours path
git checkout --theirs path
git add pathDuring rebase, ours/theirs swap: "theirs" = the commits being replayed.
Strategy (-s) vs Strategy Option (-X)
- Strategy (
-s) picks the algorithm:ort(default),recursive,resolve,octopus,ours,subtree. - Option (
-X) tunes a strategy.-X oursonly breaks ties; non-conflicting changes still merge.
git merge -X ours feature # merge all, prefer ours on conflict
git merge -s ours feature # fake-merge: record, keep tree unchanged
git merge -X ignore-all-space feature
git merge -X patience feature # better diff for reordered blocks-s ours says "we abandon their work but don't want future merges replaying it."
Inspecting
git ls-files -u # stages 1=base, 2=ours, 3=theirs
git show :1:f > base; git show :2:f > ours; git show :3:f > theirs
git merge-file -p ours base theirs > resolved
git log --merge -p path # commits on either side touching file
git log --left-right HEAD...MERGE_HEADAbort
git merge --abort # before committing
git reset --merge # equivalentUndoing a Completed Merge
Local only: git reset --hard ORIG_HEAD
Already pushed: git revert -m 1 <merge-sha> (keep mainline, drop feature side).
Gotcha: after revert -m 1, re-merging the same branch pulls only new commits — Git thinks the rest is already merged. Fix:
git revert <revert-commit> # un-revert
git merge feature # clean re-mergePitfalls
- No
-s theirsexists; do-s ourson the other branch then merge back. - Octopus strategy refuses to auto-resolve conflicts.
- For recurring conflicts, enable rerere.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

