Roadmap › Git & GitHub — Version Control from Basics to Advanced › Module: Working in a Team
Lessons in this course (10)
4. Merge conflicts — why they happen and how to resolve them
Intermediate★ Must knowLesson 4 of 10
A conflict happens when two branches change the same lines (or one edits a file the other deleted) and Git can't decide.
text
<<<<<<< HEAD
decimal discount = 0.10m;
=======
decimal discount = GetDiscount(customer);
>>>>>>> feature/discountsSteps:
git status— lists conflicted files.- Edit each file: keep one side, both, or write a new combination; remove the markers.
- Build and run tests.
git add <file>thengit commit(merge) orgit rebase --continue(rebase).- Changed your mind:
git merge --abort/git rebase --abort.
Reduce conflicts: small PRs, merge main into long branches often, agree formatting (.editorconfig, Prettier), avoid giant files everyone edits.