{"data":{"slug":"discovered-f0359ba31f768e8dec7da248bc295b5841b72341a39346a9","title":"Concurrent Branches","summary":"Resolve conflicts and merges when multiple branches are open against one repo, focusing on hotspot files, union-vs-recompute-vs-rebuild resolutions, and generated artifacts that must never be merged.","url":"https:\/\/skillshunter.net\/skills\/discovered-f0359ba31f768e8dec7da248bc295b5841b72341a39346a9","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-f0359ba31f768e8dec7da248bc295b5841b72341a39346a9","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-f0359ba31f768e8dec7da248bc295b5841b72341a39346a9.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-f0359ba31f768e8dec7da248bc295b5841b72341a39346a9\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before resolving conflicts, run the repo's actual CI commands locally to ensure the merged code is valid. Recompute single-value counters (like version fields) from the current integration branch, not from either side of the conflict. Always rebuild generated artifacts rather than merging them.","instructions":"---\nname: concurrent-branches\ndescription: Resolve conflicts and merges when several branches are open against one repo at the same time \u2014 the hotspot files every change must touch (registry manifests, a single version field, shared tool config, one aggregated test module, tracked build output), union-vs-recompute-vs-rebuild as three different correct resolutions, generated artifacts that must never be merged, non-deterministic serialization that makes every branch conflict, renumbered identifiers that git cannot show you, and why a clean auto-merge is not a passing test. Use when rebasing or merging a long-lived branch, resolving conflict markers, reviewing a merge commit, deciding what a repo should commit vs generate, or setting up a repo that will take parallel contributions.\n---\n\n# Merging Concurrent Branches\n\nWhen several branches are open against the same repo at once, the conflicts do\nnot land in the code you were thinking about. They land in a small, predictable\nset of **hotspot** files that nearly every change has to touch \u2014 a registry\nmanifest, a version field, shared tool config, one aggregated test module, a\ntracked build output.\n\nEach hotspot has exactly one correct resolution, and they are not the same rule.\n\"Take ours\" \/ \"take theirs\" is right for almost none of them. Worse, getting one\nwrong is silent: the dropped entry, the collided version, the stale bundle all\nmerge green and are found later by someone who cannot reproduce them.\n\n## Find the hotspots before you need to resolve them\n\nFiles touched by nearly every commit are the files your branch will conflict on.\n\n```bash\n# the 15 files most commits touch \u2014 your hotspot list\ngit log --format= --name-only -n 200 | sort | uniq -c | sort -rn | head -15\n```\n\nWrite the resolution rule for each one into the contributing docs. Under\nconflict pressure, with a stale branch and a red CI run, nobody re-derives\n\"the version field is recomputed, not merged\" correctly.\n\n## Additive registries: union both sides, never choose one\n\nA manifest that lists every component \u2014 plugin entries, module paths, exported\nnames, a feature list. Two branches each append an entry, and the conflict spans\nboth additions:\n\n```jsonc\n<<<<<<< HEAD\n    \".\/components\/exporter\",\n    \".\/components\/importer\"        \/\/ theirs, already merged to main\n=======\n    \".\/components\/exporter\",\n    \".\/components\/validator\"       \/\/ yours\n>>>>>>> feature\/validator\n```\n\nBoth sides are correct and neither is a substitute for the other. Resolve by\nkeeping **every** entry from both sides. Taking a side deletes a component that\nis still fully present in the tree \u2014 the code compiles, the tests pass, and the\ncomponent is simply never registered or installed.\n\nNothing catches that unless you check the registry against the filesystem:\n\n```bash\n# every registered path exists\njq -r '.plugins[].components[]' manifest.json | while read -r p; do\n  [ -e \"${p#.\/}\" ] || echo \"registered but missing: $p\"\ndone\n# every component on disk is registered\nfor d in components\/*\/; do\n  grep -q \"\\\".\/${d%\/}\\\"\" manifest.json || echo \"present but unregistered: $d\"\ndone\n```\n\nRun it as a repo test, not as a merge-day ritual. It is the only thing standing\nbetween a mis-resolved conflict and a component that quietly does not ship.\n\n## Single-value counters: recompute from the integration branch\n\nA version field, a sequence number, a \"latest migration\" pointer. Both branches\nbumped `2.17.0` to `2.18.0`; both are wrong now, because a third branch already\nmerged and main is at `2.18.0` too.\n\nUnion is meaningless here and picking a side reintroduces a collision. The rule\nis **recompute from the current integration branch**, not from either side of\nthe conflict \u2014 every change that merged since you branched consumed one\nincrement:\n\n```bash\ngit fetch origin main\ngit show origin\/main:manifest.json | jq -r '.metadata.version'   # -> 2.18.0\n# your branch takes 2.19.0, regardless of what your branch said before\n```\n\nDo this as the *last* step before pushing, not during the merge. If another\nbranch lands while you resolve, you redo only one line.\n\n## Generated artifacts: rebuild, never merge\n\nA committed minified bundle, a built PDF, a compiled schema, a checked-in\nsnapshot. Git will happily produce a merge for the text ones and force a\nbinary choice for the rest \u2014 and **every** such result is wrong, because a\nderived file's only correct content is whatever the merged sources generate.\n\nResolve the sources, then regenerate:\n\n```bash\ngit checkout --merge -- src\/ ui\/app.jsx   # resolve the real inputs first\nmake build                                 # regenerate the artifact\ngit add dist\/bundle.js docs\/handbook.pdf\n```\n\nTwo things make this reviewable rather than a leap of faith:\n\n- **Pin the generator version.** If the bundler or typesetter is pinned, its\n  output is byte-identical anywhere, and a reviewer can regenerate and `diff` to\n  confirm the artifact matches the source. Unpinned, the artifact diff is a mix\n  of your change and a tool upgrade, and nobody can tell them apart.\n- **Verify only the expected regions moved.** A rebuilt document reflows: a\n  one-paragraph edit typically spreads across two or three consecutive pages.\n  Raster-diff or `diff` the rebuilt artifact against one built from the base\n  commit in the same environment, and say in the PR which regions changed and\n  why. Anything else that moved is your merge, not your edit.\n\n## Non-deterministic serialization turns every branch into a conflict\n\nIf a tracked file is written by iterating a map, set, or dict whose order is not\nstable, the whole file is rewritten on every run. Then every branch conflicts on\nevery line, diffs are unreviewable, and real conflicts hide inside the churn.\n\nSort before writing:\n\n```python\n# BAD \u2014 map iteration order; the file is rewritten differently every time\nrecords = [to_record(k, v) for k, v in index.items()]\n\n# GOOD \u2014 a stable key. ISO-8601 dates sort chronologically as plain strings,\n# so no date parsing is needed to get a deterministic, reviewable file.\nrecords = sorted((to_record(k, v) for k, v in index.items()), key=lambda r: r[\"date\"])\n```\n\nThis applies to *any* code path that rebuilds a committed file from an unordered\ncollection, including the ones added later. Once one path forgets, the file is\nchurny again.\n\n## Shared tool config: take the base file, re-apply your delta\n\n`pyproject.toml`, `package.json`, lint config, a CI workflow \u2014 files where your\nbranch added three lines and four other branches added their own. Reconciling\nhunks by hand is where dev-dependency pins and tool sections get silently\ndropped.\n\nTake the integration branch's copy wholesale \u2014 it already carries everything\nthat landed while you were away \u2014 then re-add only the lines your branch\nintroduced:\n\n```bash\ngit checkout origin\/main -- pyproject.toml\n# re-add just your delta, then confirm nothing else moved\ngit diff origin\/main -- pyproject.toml\n```\n\nThat last `git diff` should show your addition and nothing else. If it shows a\npin reverting or a tool section disappearing, you took a side by accident.\n\n## Aggregated test modules: keep both suites, then check for shadowing\n\nTwo branches append cases to the same test file. Union them \u2014 but a union can\nproduce two tests with the same name, and in Python and JavaScript the later\ndefinition simply replaces the earlier one. The file looks longer, the suite\ncount looks plausible, and one branch's case never runs.\n\n```bash\ngrep -oE '^\\s*(def test_[A-Za-z0-9_]+|it\\(.[^,]*|test\\(.[^,]*)' tests\/test_thing.py \\\n  | sort | uniq -d\n```\n\nThe same shape bites production code: two branches independently add the same\nmodule-level helper, the resolution keeps both, and the second shadows the\nfirst.\n\n## Append; never renumber a shared identifier\n\nRepos that carry stable identifiers cited from elsewhere \u2014 claim IDs in a source\nledger, migration numbers, fixture keys, snapshot names \u2014 break in a way conflict\nmarkers cannot show you. Renumbering `C7`-`C12` to make room is a clean,\nconflict-free edit that invalidates every citation of those IDs in files your\nmerge never touched.\n\nAdd new identifiers by continuing the numbering past the highest one that exists\nanywhere, and never reuse or renumber one. If two branches both claimed `C17`,\nrenumber **yours** and fix your own references; do not renumber the side that\nalready merged.\n\n## A clean auto-merge is not verification\n\nTwo branches editing far-apart regions of one large file merge cleanly and can\nstill be semantically wrong: one side's change depends on a helper the other\nremoved, or both added equivalent logic under different names, or one side's\nedit now sits inside a branch the other made unreachable.\n\nAfter any non-trivial merge, confirm both sides survived \u2014 grep the merged tree\nfor a distinctive string from each:\n\n```bash\ngit grep -n \"computes the retry budget\"     # a phrase only their change added\ngit grep -n \"REDACTION_PLACEHOLDER\"         # a symbol only yours added\n```\n\nPresent and consistent, not just present. Then read the two regions together.\n\n## Match the repo's integration style, and re-run the real gate\n\n```bash\ngit log --graph --oneline -20    # merge commits, or a linear rebased history?\n```\n\nFollow whichever the history already uses. Then run the repo's actual CI\ncommands locally before pushing: **a resolved merge is code that has never\nexisted anywhere before**, and neither branch's CI run covered it. A green check\non your branch and a green check on main say nothing about their union. See\n**reproducing-ci-locally** for deriving the commands the runner actually uses.\n\n## Checklist\n\n- [ ] Hotspot files identified from `git log --name-only` before branching\n- [ ] Registry\/manifest conflicts resolved by union; every entry from both sides kept\n- [ ] Registry checked against the filesystem in both directions, in CI\n- [ ] Version\/counter fields recomputed from `origin\/main`, not taken from either side\n- [ ] Generated artifacts rebuilt from merged sources, never text- or binary-merged\n- [ ] Generator version pinned so a reviewer can regenerate and diff\n- [ ] Files serialized from maps\/sets sorted by a stable key\n- [ ] Shared tool config taken from base, delta re-applied, `git diff` shows only your lines\n- [ ] Merged test modules checked for duplicate test names\n- [ ] New shared identifiers appended; none reused or renumbered\n- [ ] A distinctive string from each side found in the merged tree\n- [ ] Repo's real CI gate run locally on the merged result before pushing\n\n## Note for this repository (ffmpeg-skill)\n\nThis is exactly the pattern seen across the PR #28-#37 merge cascade for the\n0.10.0 release: `CHANGELOG.md` was the hotspot file nearly every PR touched,\nand the correct resolution every time was \"union both sides, never choose\none\" (keep every bullet, verify no leftover conflict markers). `package.json`'s\n`version` field is the single-value-counter case: it should be recomputed\nonce, after all merges land, not carried through each individual merge.\n\n## Learn More\n\n- **reproducing-ci-locally** (also added to this repo's `.claude\/skills\/`) \u2014\n  running the runner's real commands on the merged tree\n\nSource: [wdm0006\/python-skills](https:\/\/github.com\/wdm0006\/python-skills) (MIT).\n","use_cases":["Resolving conflicts during a long-lived branch rebase","Reviewing a merge commit with multiple overlapping changes","Setting up a repo for parallel contributions","Deciding what a repo should commit versus generate","Ensuring all components are registered and present in the filesystem"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/kajisho5\/ffmpeg-skill\/blob\/daae28ea4fe27223932392be07206798423c0f8b\/.claude\/skills\/concurrent-branches\/SKILL.md","source_commit":"daae28ea4fe27223932392be07206798423c0f8b","license":null,"version":null,"listing_approved_at":"2026-11-28","created_at":"2026-11-28T08:11:06.000000Z","updated_at":"2026-11-28T18:38:03.000000Z","seo_title":"Concurrent Branches Conflict Resolution","seo_description":"Learn how to resolve conflicts and merges when multiple branches are open against one repo, including handling hotspot files, additive registries, and generated artifacts","seo_keywords":["concurrent branches","git merge resolution","conflict resolution","additive registries","generated artifacts","recompute version fields","hotspot files","union vs recompute vs rebuild"]}}