Merge Conflicts & Resolution
Merge conflicts are inevitable in team development. A DevOps engineer who can quickly and correctly resolve conflicts keeps the team moving. Conflicts happen when multiple developers edit the same lines of the same file.
Why Conflicts Happen
- Two developers edit the same line in the same file on different branches
- One developer deletes a file that another developer modified
- A file was renamed on one branch and edited on another
- Prevention: commit often, keep branches short-lived, pull from main daily
Resolving Conflicts Step by Step
# When you run git merge and get conflicts:
$ git merge feature/new-api
Auto-merging src/api/users.ts
CONFLICT (content): Merge conflict in src/api/users.ts
Automatic merge failed; fix conflicts and then commit the result.
# The conflict markers look like this in the file:
# <<<<<<< HEAD (your current branch)
# const apiVersion = "v1";
# =======
# const apiVersion = "v2";
# >>>>>>> feature/new-api (incoming branch)
# Steps to resolve:
# 1. Open the conflicted file
# 2. Decide which version to keep (or combine both)
# Example resolution:
const apiVersion = "v2"; // We chose feature/new-api's version
# 3. Remove ALL conflict markers (<<<<<<<, =======, >>>>>>>)
# 4. Stage the resolved file
git add src/api/users.ts
# 5. Complete the merge
git commit -m "fix: resolve merge conflict in api version"
# VS Code makes this much easier:
# Open the file with conflicts → VS Code shows:
# [Accept Current Change] [Accept Incoming Change] [Accept Both] [Compare]
# Click the appropriate option for each conflict
# To abort a merge that went wrong:
git merge --abortQuick Quiz
Tip
Tip
Practice Merge Conflicts Resolution in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Observability = Metrics + Logs + Traces. Can't fix what you can't see.
Practice Task
Note
Practice Task — (1) Write a working example of Merge Conflicts Resolution from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Common Mistake
Warning
A common mistake with Merge Conflicts Resolution is skipping edge case testing — empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready devops code.
Key Takeaways
- Merge conflicts are inevitable in team development.
- Two developers edit the same line in the same file on different branches
- One developer deletes a file that another developer modified
- A file was renamed on one branch and edited on another