Sub topic 12
Handling conflicts between work items
This chapter assumes you know Git branches, merges and pull requests. It also assumes you have followed the earlier chapters on work items, committing changes and promotion. You should know that each work item has its own branch and that a pipeline stage maps to a branch in the repository.
Why conflicts happen in DevOps Center
DevOps Center gives every work item its own feature branch. Two people can change the same metadata component in different work items at the same time. When both changes reach the same stage branch, Git cannot decide which version to keep. That is a conflict.
Conflicts are normal in a team. They show up in three places:
- Pull request into the first stage. Two work items edited the same lines of one file.
- Promotion to a later stage. A work item was merged into an earlier stage, but another change reached the later stage first by a different route, such as a hotfix.
- Bundled promotion. Several work items are promoted together and they overlap.
Metadata makes this worse in some cases. Profiles, permission sets, page layouts and flows are stored as large XML files. Many unrelated changes land in the same file, so Git sees them as overlapping even when the intent differs.
How DevOps Center reports a conflict
DevOps Center checks for conflicts at specific points. The exact wording changes between releases, so treat the descriptions below as the general behavior.
- When you open the pull request. The work item shows the pull request status. If the branch cannot merge cleanly, the merge is blocked.
- When you promote. DevOps Center tries to merge the work item's changes into the next stage's branch. If the merge cannot complete, the work item shows a conflict state and does not move forward.
- When you pull changes into a work item. If the org holds changes that clash with the branch, you resolve which version to keep before committing.
A work item that is blocked stays where it is. Nothing is deployed in a half-merged state. Your job is to bring the branch up to date and fix the overlap.
Resolving a conflict
You resolve conflicts with Git, not inside the DevOps Center screens. The usual route is to update the work item branch with the latest stage branch, fix the files, and push.
git fetch origin
git checkout feature/WI-102
git merge origin/mainIf the merge reports conflicts, Git marks the affected files. Open each one and look for the markers:
<<<<<<< HEAD
<label>Customer Tier</label>
=======
<label>Account Tier</label>
>>>>>>> origin/mainKeep the correct content, remove all three marker lines, and check that the XML is still valid. Then finish the merge and push.
git add force-app/main/default/objects/Account/fields/Tier__c.field-meta.xml
git commit -m "Resolve conflict with main for WI-102"
git push origin feature/WI-102After the push, return to DevOps Center. The pull request should now be mergeable. If the work item still shows the old state, refresh the page. You can also resolve the conflict on the Git provider's pull request page if it offers a web editor.
Check that the result still deploys
A clean Git merge does not guarantee a valid deployment. Two edits can merge without a conflict and still break each other. For example, one work item deletes a field and another adds a layout that uses it. Run a validation-only deploy before you go on:
sf project deploy start --source-dir force-app --target-org uat --dry-run --test-level RunLocalTestsThe --dry-run flag validates without saving anything in the org. See the chapter on validation and test gates for details.
Conflicts that Git does not flag
Some collisions are logical rather than textual. Watch for these:
- Different files, same behavior. Two flows on the same object both update one field.
- Dependency removal. One work item removes a component that another still references.
- Order of operations. A work item assumes a field exists that is only in a work item awaiting review.
- Org-only drift. Someone changed a stage org directly, so it no longer matches its branch.
Code review is where you catch most of these. Ask reviewers to check which other open work items touch the same components.
Choosing which version to keep
| Situation | Typical decision |
|---|---|
| Both edits are independent additions in one XML file | Keep both and check the XML is valid |
| Both edits change the same value | Ask the two authors and agree on one |
| One edit is a delete, the other a change | Decide whether the component should exist at all |
| The file is a profile or permission set | Keep both permission entries and re-validate |
Never pick "ours" or "theirs" for a whole file without reading it. That silently discards another person's work.
Reducing conflicts before they happen
- Keep work items small. A short-lived branch has fewer chances to overlap.
- Promote often. Work items that sit in review fall behind the stage branch.
- Split large metadata. Use permission sets instead of editing profiles. Avoid changing the same layout in several work items.
- Talk before you start. If two people need the same object, agree on the order.
- Update branches regularly. Merge the stage branch into your work item branch before you open the pull request.
Common mistakes
- Committing files that still contain conflict markers. The deployment fails with an XML parse error.
- Resolving the conflict on the wrong branch, such as the stage branch instead of the work item branch.
- Forgetting to push after a local merge, so DevOps Center still sees the old branch.
- Skipping validation because Git reported success.
Exercise
Work items WI-101 and WI-102 both edit the same lines of an object file. WI-101 merged into the main branch first. WI-102 is now blocked. Which steps should you take to unblock it, and what should you do before promoting?
Show answer
Fetch the latest remote, check out the WI-102 branch, and merge the main branch into it. Open each conflicted file, decide which content to keep (after talking with the WI-101 author if the values differ), remove the conflict markers, and confirm the XML is valid. Add and commit the files, then push the WI-102 branch so the pull request becomes mergeable. Before promoting, run a validation-only deployment with local tests against the target org to catch problems that Git cannot see, such as a layout referencing a deleted field.
Exercise
Git merged two work items with no conflict, but the deployment to UAT fails. Name two possible causes.
Show answer
The changes are logically incompatible even though they touch different lines or files. For example, one work item deleted a field that the other work item's layout or flow still references. Another cause is org drift, where the UAT org was changed directly and no longer matches its branch.