A merge conflict occurs in version control systems like Git when two different changes to the same file cannot be automatically merged. This happens when multiple developers are working on the same parts of a file simultaneously, and their changes clash.
Imagine two developers are working on the same file in a project:
main
).feature-branch
).When Developer B tries to merge their branch (feature-branch
) with the main branch (main
), Git detects that the same line has been changed in both branches and cannot automatically decide which change to keep. This results in a merge conflict.
In the file, a conflict might look like this:
<<<<<<< HEAD
Change by Developer A
=======
Change by Developer B
>>>>>>> feature-branch
Here, the developer needs to manually resolve the conflict and adjust the file accordingly.