Sub topic 12
Handling conflicts between work items
This chapter assumes you know Git branches, merges and pull requests. It also assumes you have created work items and committed changes to their branches, as covered in earlier chapters.
Why conflicts happen
Each work item has its own branch. Two work items conflict when they change the same part of the same metadata file and one of them reaches a shared branch first. Git cannot tell which edit should win, so it asks a person to decide.
Common causes:
- Two developers edit the same Apex class, flow or profile.
- One work item changes a field's metadata while another deletes the field.
- A long-running work item falls behind the stage branch it will merge into.
Profiles, permission sets and flows are the usual trouble spots. Their XML files are large, and unrelated edits often land close together.
Where DevOps Center shows a conflict
DevOps Center checks for conflicts at two points:
- When you pull or commit changes, it compares your work item branch with the pipeline's first stage branch.
- When you promote, it checks whether the work item can merge cleanly into the next stage.
When it finds a conflict, the work item shows a conflict status and the action is blocked until you resolve it.
Resolving a conflict
Resolution is a Git task. DevOps Center flags the problem, and you fix the files in your branch. A typical sequence:
- Fetch the latest state of the stage branch.
- Merge that stage branch into your work item branch.
- Open each conflicted file and choose the right content.
- Commit the merge and push the branch.
git fetch origin
git checkout WI-0042
git merge origin/UAT
# edit the files that contain conflict markers
git add force-app/main/default/flows/Case_Router.flow-meta.xml
git commit -m "Resolve merge with UAT"
git push origin WI-0042Conflict markers look like this:
<<<<<<< HEAD
<status>Active</status>
=======
<status>Draft</status>
>>>>>>> origin/UATKeep the lines you want and delete the markers. Then check that the XML is still valid.
After you push, return to DevOps Center and refresh the work item. The conflict status should clear. Retrieve the merged result into your development environment so the org matches the branch. Otherwise your next commit may undo the resolution.
Common errors
- Leaving conflict markers in the file. The deployment then fails with an XML parse error.
- Resolving in the org instead of in Git. The branch is the source of truth, so the org change is lost on the next pull.
- Keeping both sides of a profile or flow block, which produces duplicate elements and a failed deploy.
- Letting work items live for weeks. The longer a branch lives, the larger the conflict.
Exercise
Work item WI-0042 shows a conflict when you try to promote it to UAT. Where do you resolve it, and what must you do afterward so the next commit does not undo your fix?
Show answer
Resolve it in the Git branch of WI-0042 by merging the UAT branch into it, editing the conflicted files, committing and pushing. Then refresh the work item and pull the merged result into your development environment, so the org matches the branch.