Sub topic 10
Special cases: flows, layouts and bundle metadata
Earlier chapters resolved conflicts in files such as profiles and permission sets. Those files are lists of independent entries, so keeping both sides often works. Flows, page layouts and bundle metadata behave differently, and the same approach can produce a merge that parses but fails to deploy or misbehaves in the org.
This chapter assumes you can read conflict markers, keep XML well-formed, and run sf project deploy start --dry-run. It covers the three special cases and how to choose a resolution for each.
Why these types are different
A permission set is mostly a set of unordered, self-contained entries. Each fieldPermissions block stands alone. The three types in this chapter break that assumption in different ways.
| Type | Why a plain merge is risky | Usual safe approach |
|---|---|---|
| Flow | Elements point at each other by name. Canvas positions change on every save. | Take one whole version, then redo the other change in Flow Builder. |
| Page layout | Order of sections, items and related lists is part of the meaning. The files are large. | Take one side, or re-retrieve from an org. Hand-merge only small changes. |
| Bundle (LWC, Aura) | Several files form one component. Each file can merge cleanly while the component is broken. | Resolve the files as a unit and test the component. |
Flows
A flow lives in one file, force-app/main/default/flows/<ApiName>.flow-meta.xml. The file holds every element of the flow: screens, decisions, assignments, record lookups, and the connectors between them.
Three properties make flow conflicts harder than permission set conflicts.
- Elements reference each other by name. A decision's
connectorholds atargetReferencenaming the next element. If one branch renames or deletes an element and the other branch connects to it, the merge can produce a dangling reference. Git cannot detect that, because the XML is still well-formed. - Canvas coordinates change constantly. Each element stores
locationXandlocationY. Dragging one element in Flow Builder, or even saving after adding one, can change values on lines unrelated to your logic change. Two people editing the same flow often conflict on position lines only. - The file holds one version. Salesforce keeps several versions of a flow in an org, but source format holds only the version you retrieved. A conflict is therefore about two edits to one version. Check the
<status>value (Active,Draft,Obsolete) as part of the merge. If one branch activated the flow and the other left it as a draft, you must pick on purpose. Do not let the markers decide.
Here is a typical conflict where both branches added an element at the same spot:
<<<<<<< HEAD
<assignments>
<name>Set_Tier</name>
<label>Set Tier</label>
<locationX>176</locationX>
<locationY>335</locationY>
<assignmentItems>
<assignToReference>$Record.Tier__c</assignToReference>
<operator>Assign</operator>
<value>
<stringValue>Gold</stringValue>
</value>
</assignmentItems>
<connector>
<targetReference>Update_Account</targetReference>
</connector>
</assignments>
=======
<assignments>
<name>Set_Segment</name>
<label>Set Segment</label>
<locationX>440</locationX>
<locationY>335</locationY>
<assignmentItems>
<assignToReference>$Record.Segment__c</assignToReference>
<operator>Assign</operator>
<value>
<stringValue>Enterprise</stringValue>
</value>
</assignmentItems>
<connector>
<targetReference>Update_Account</targetReference>
</connector>
</assignments>
>>>>>>> feature/segmentKeeping both blocks yields valid XML, but it is probably wrong. Both new assignments connect to Update_Account, and neither is connected from the start of the flow. Something earlier in the flow must route to them, and that routing lives in other parts of the file. The two edits may be incompatible.
For a flow, use this order of preference:
- If only one branch changed logic and the other changed only positions, take the logic branch and ignore the position differences.
- If both branches changed logic, take one whole file with
git checkout --oursor--theirs. Open it in Flow Builder and redo the other change by hand. This is slower than editing XML, but Flow Builder checks the references for you. - Hand-merge the XML only for a small, clearly independent change, such as a label edit and a description edit in different elements.
A flow's logic is only trustworthy once the org accepts it. Run a dry run on the flows directory and then open the flow in Flow Builder, which flags broken connectors visually.
sf project deploy start --dry-run --source-dir force-app/main/default/flows --target-org my-sandboxPage layouts
A layout file such as Account-Account Layout.layout-meta.xml is one long document of layoutSections, layoutItems, relatedLists and platformActionList entries. Two properties matter for merging.
- Order is meaning. Moving a field up one row is a real change. A hand merge can silently reorder fields so that they differ from what either author intended.
- The files are generated and noisy. Salesforce rewrites a layout whenever someone saves it in Setup, and retrieving it again can reorder or add entries. A large conflict often reflects two retrievals of the same layout rather than two meaningful edits.
Layout file names also carry special characters. In source format, characters such as spaces, parentheses and percent signs are URL-encoded, so a layout named Account (Marketing) Layout becomes Account-Account %28Marketing%29 Layout.layout-meta.xml. Always quote paths in shell commands.
For a layout conflict, first decide whether the two sides are meaningfully different. If one side is only a noise-level regeneration, take the other side. If both sides contain real changes, take one side and redo the second person's change in the org's layout editor, then retrieve again.
# During a merge, "theirs" is the branch you are merging in
git checkout --theirs -- "force-app/main/default/layouts/Account-Account Layout.layout-meta.xml"
git add "force-app/main/default/layouts/Account-Account Layout.layout-meta.xml"The meaning of --ours and --theirs flips during a rebase. In a rebase, --ours is the branch you are rebasing onto, and --theirs is your own commit being replayed. Check which side you are taking by opening the file before you stage it.
Bundle metadata
A bundle is a directory of files that together define one component. Lightning Web Components, Aura components and Experience Cloud bundles all work this way. An LWC looks like this:
force-app/main/default/lwc/accountCard/
accountCard.html
accountCard.js
accountCard.css
accountCard.js-meta.xmlGit merges each file separately, so a bundle can end with every file merged cleanly and the component still broken. For example, branch A removes a property from accountCard.js, and branch B adds {tier} to accountCard.html. Neither file conflicts. The component fails at runtime because the template uses a property that no longer exists.
For bundles, treat the directory as the unit of resolution.
- List every changed file in the bundle, not only the conflicted ones:
git diff --name-only HEAD MERGE_HEAD -- force-app/main/default/lwc/accountCard. - Read the JavaScript and the template together. Check that each name the template uses is defined in the class.
- Check
.js-meta.xmlfortargetsandapiVersion. A conflict there is the same kind of XML conflict as before, but a wrongtargetslist changes where admins can place the component. - Run the component's Jest tests if the project has them, and do a dry-run deployment of that directory.
Delete and rename conflicts
Bundles also produce conflicts that have no markers. If one branch deleted a component and the other edited a file in it, Git reports a modify/delete conflict.
git merge feature/remove-old-card
# CONFLICT (modify/delete): force-app/main/default/lwc/oldCard/oldCard.js deleted in feature/remove-old-card and modified in HEAD.
# Automatic merge failed; fix conflicts and then commit the result.
git status --short
# DU force-app/main/default/lwc/oldCard/oldCard.js
# UD ... or AA, AU, UA for add conflicts
# Decision A: the component should go away
git rm -r force-app/main/default/lwc/oldCard
# Decision B: the edit matters, so keep the component
git add force-app/main/default/lwc/oldCardNo file contains markers here, so grep for marker lines will not find these conflicts. Use git diff --name-only --diff-filter=U to list every unresolved path. If you delete a component, also search for references to it in other components, flows and Lightning pages.
Choosing a strategy
Common mistakes
- Keeping both sides of a flow without checking connectors. The XML is valid but the flow logic is not.
- Resolving only the files that show markers in a bundle. Clean merges in sibling files can still break the component.
- Using
--theirsduring a rebase. It picks your own commit, not the target branch. - Forgetting the quotes around layout paths. Spaces and
%28sequences split or change the argument. - Treating a layout conflict as a content dispute. Often both sides are the same layout retrieved at different times.
Exercise
Two developers each added a different assignment element to the same flow. Git reports a conflict. You keep both blocks and the XML parses with xmllint. Why is the resolution still not safe to commit, and what should you check next?
Show answer
Valid XML does not mean valid flow logic. Elements reference each other by name through connector and targetReference, and nothing may route to the new assignments or both may connect to the same target. Run a dry-run deployment of the flows directory and open the flow in Flow Builder to check the connectors. If the changes interfere, take one whole side and redo the other change in Flow Builder.
Exercise
After merging a branch, no file in force-app/main/default/lwc/oldCard contains conflict markers, yet git status shows DU for oldCard.js. What does it mean, and how do you resolve it?
Show answer
DU means the file was deleted on your side and modified on the other, or the reverse for UD. This is a modify/delete conflict, which has no markers. If the component should be removed, run git rm -r on the directory. If the edit must be kept, run git add on the file or directory to keep it. Then search for other references to the component before committing.