
Serpent Team

Andrew Hanna

Short answer: Most Salesforce merge conflicts are not real disagreements. They are two people adding unrelated things to the same oversized XML file, or the same elements coming back in a different order. Combine both sides for additive metadata like profiles, permission sets, layouts and labels, and never hand-merge generated XML like Flows: pick one version and re-apply the other change in Flow Builder.
Four platform quirks cause almost all of them.
The worst offenders, and almost always additive. Two branches each add an
objectPermissions or fieldPermissions block and the
additions land next to each other. Take both sides, then de-duplicate on the key
element (field, object, apexClass) and re-sort.
Never resolve a profile by accepting one side wholesale.
Worth knowing: Salesforce has cancelled the retirement of permissions in profiles (Salesforce Help article 003834041), so profiles are not going away on a clock and this problem does not solve itself. Salesforce still recommends a least-privilege model built on permission sets, and moving permissions off profiles genuinely shrinks the conflict surface, because permission sets are small, per-feature files.
Do not hand-merge them. The XML carries generated element names and canvas coordinates, so a line-level merge produces something that looks plausible and behaves wrongly. Choose one version as the winner and re-apply the other change in Flow Builder.
Layout XML lists every item in position order, so two people adding fields to
different sections still collide if the sections are adjacent. Combine both sides,
then check that every layoutItem from each parent survived. If a
Lightning record page conflict runs to more than a few lines, rebuild it in the
Lightning App Builder rather than merging it.
If your repo stores an object as one file, every field change touches it. Decomposed source format gives each field its own file and removes most of these conflicts before they happen.
Treat these as normal code conflicts, because they are. Resolve the logic, re-run the tests, and then check that the class is still granted in the profiles and permission sets that reference it.
Single alphabetical files, purely additive. Take both sides and re-sort.
This guide is part of our Salesforce DevOps guides.
Can Git resolve Salesforce metadata conflicts on its own?
Only textually. Git cannot tell that two profile blocks are independent or that a reordered file is unchanged, so it raises false conflicts and will happily accept a merge that is semantically wrong.
What is a false conflict?
A conflict where both sides hold the same metadata in a different order. The Metadata API does not guarantee element order, so two retrievals can differ with no real change behind them.
Should I ever hand-edit Flow XML to resolve a conflict?
No. Pick one version and re-apply the other change in Flow Builder, then commit what you retrieve.
Why do profiles conflict when we worked on completely different features?
A profile is a single file covering permissions for every object, field and class in the org, so unrelated features end up writing to adjacent lines.
How do I check the merge did not lose anything?
Diff the merged file against both parent versions, confirm every key element from each side survived, and validate the deployment against the target org before merging.
Commitment free!