Interview Prep/DevOps Fundamentals/Branching, versioning & releases

What is a merge conflict, and how do you resolve it?

BeginnerConceptBranching, versioning & releases
Answer

In one line: A merge conflict happens when two branches change the same lines of a file (or one deletes a file the other changed), and Git can't decide which version to keep — so a person has to choose.

What it looks like:

<<<<<<< HEAD
replicas: 3
=======
replicas: 5
>>>>>>> feature/scale-up
  • Between <<<<<<< and =======: your current branch's version.
  • Between ======= and >>>>>>>: the incoming branch's version.

How to resolve it:

  1. Update your branch: git fetch then git merge origin/main (or git rebase origin/main).
  2. Git lists the conflicted files (git status).
  3. Open each file, decide the correct final content (yours, theirs, or a combination), and remove the markers.
  4. Mark it resolved: git add <file>.
  5. Finish: git commit (for a merge) or git rebase --continue (for a rebase).
  6. Run the tests again — a cleanly resolved conflict can still break the logic.
  7. Push and let CI run.

If you get lost: git merge --abort or git rebase --abort takes you back to before you started.

How to avoid conflicts:

  • Small, short-lived branches and frequent merges from main.
  • Communicate when several people work on the same file.
  • Split big files and configs into smaller ones.
  • Use formatters so style changes don't create conflicts.

DevOps example: two engineers change the same Helm values.yaml — one updates the image tag, the other the memory limit. Both changes are needed, so the resolved file keeps the new tag and the new limit.

Tip for interviews: explain the steps and mention running tests after resolving — many candidates forget that.

All DevOps Fundamentals questions

More on Branching, versioning & releases