Learn what merge conflicts are, why they happen, and the process for resolving them in Git.
A merge conflict is an event that occurs when Git is unable to automatically resolve differences in code between two commits. This typically happens when you try to merge a branch into another branch that has had conflicting changes made since the feature branch was created. For example, imagine you are working on a feature branch and you change a line of code in `app.js`. At the same time, another developer merges a change to the *exact same line* of code in `app.js` into the `main` branch. When you later try to merge your feature branch into `main`, Git won't know which change to keep. It can't read your mind to decide if your change or the other developer's change is the correct one. Git will pause the merge process and mark the file as having a conflict. When you open the conflicted file, you will see special markers (`<<<<<<< HEAD`, `=======`, `>>>>>>> branch-name`) that Git has added. These markers surround the conflicting code blocks—the version from your current branch (`HEAD`) and the version from the branch you are trying to merge. Your job is to manually edit the file to resolve this conflict. You must decide which code to keep, or perhaps combine the changes in a new way. Once you have edited the file to look exactly how you want it, you save it, use `git add` to mark the conflict as resolved, and then continue the merge with `git commit`.