How do custom merge drivers and `merge=union` work?
AdvancedConceptGitHub features, history rewriting and scale
Answer
In .gitattributes you assign a merge driver per path. Built-ins include union (keep lines from both sides, useful for changelogs) and binary. A custom driver is defined in config and receives the base, ours and theirs files as %O %A %B, writing the result into %A.
CHANGELOG.md merge=union
package-lock.json merge=lockfile
git config merge.lockfile.driver "npm install --package-lock-only --no-audit"
More on GitHub features, history rewriting and scale
What does a GitHub Actions workflow look like at a basic level?BeginnerWhat are GitHub environments and what protection do they offer?IntermediateWhat is a GitHub Release and how does it relate to a Git tag?BeginnerWhat are the permissions of `GITHUB_TOKEN` and how do you restrict them?IntermediateWhy do fork PRs get no secrets, and what is `pull_request_target`?AdvancedWhat is the difference between a GitHub fork and a clone?Beginner