Sub topic 10
Special cases: flows, layouts and bundle metadata
This chapter assumes you can read conflict markers, keep XML well-formed, and run git merge and sf project deploy start in a Salesforce DX project. Earlier chapters showed how to keep both sides of an additive change. Three kinds of metadata need a different approach, because a merge that is valid XML can still be wrong.
Flows
A flow is one XML file per flow, for example flows/Case_Router.flow-meta.xml. Its elements point at each other by name. A <connector> holds a <targetReference> that must match the <name> of another element.
If two branches both edit a flow, Git can only compare lines. A clean-looking merge can leave:
- a connector that points to an element the other branch deleted,
- two elements with the same
<name>, - a decision whose outcomes no longer lead anywhere.
Flow Builder also rewrites the whole file on save. It can reorder elements and change locationX and locationY values, so the diff is noisy even for a small change.
Do not merge flows by hand unless the change is tiny. Take one side, then redo the other branch's change in Flow Builder:
git checkout --theirs -- force-app/main/default/flows/Case_Router.flow-meta.xml
git add force-app/main/default/flows/Case_Router.flow-meta.xmlDuring a merge, --theirs is the branch you are merging in. During a rebase the meaning is reversed, so check with git log before you run it.
Layouts
A layout lists layoutSections, and each section lists layoutItems. Their order is the order users see on the page. Two people moving fields in one layout produce conflicts that look random.
Keep the side that has more of the intended changes. Then open the layout in a sandbox and add the missing fields in the page layout editor. For layouts this is often faster and safer than editing the XML.
Bundle metadata
Lightning web components and Aura components are folders of files that work together:
- A component has
.html,.js,.cssand.js-meta.xmlfiles. - An Aura bundle has
.cmp, controller, helper and design files.
Each file can conflict on its own, and they must agree. If the template uses {recordLabel}, the JavaScript class needs a matching property. Resolve a bundle as a unit, because a fix to one file can be undone by a different choice in the next.
For a bundle conflict:
- List the conflicted files in the bundle folder with
git diff --name-only --diff-filter=U. - Resolve them in this order: JavaScript, then template, then CSS, then
-meta.xml. - Check
.js-meta.xmlforapiVersionandtargets. Keep the higherapiVersiononly if the code works with it.
Choosing a strategy
| Type | Merge by hand? | Safer option |
|---|---|---|
| Flow | Rarely | Take one side, redo the change in Flow Builder |
| Layout | Sometimes | Take one side, adjust in the editor |
| Bundle | Yes, as code | Resolve all files together, then test |
Common errors
- Keeping both flow versions and leaving duplicate element names.
- Using
--theirsduring a rebase and keeping the wrong side. - Resolving
.jsbut not the.htmlthat depends on it.
Always run sf project deploy start --dry-run afterwards. It catches dangling flow references and broken bundles before they reach an org.
Exercise
You merge a branch and Case_Router.flow-meta.xml conflicts. Both branches added a new decision element. Why is "keep both sides" risky here, and what do you do instead?
Show answer
Git merges lines, not flow logic. Keeping both sides can leave duplicate element names or connectors pointing to elements that no longer exist, and the XML can still parse. Take one side with git checkout --theirs (or --ours), add it, redo the other branch's decision in Flow Builder, then run a deployment dry run.