Merge Conflict: When Git can't combine two changes automatically because both edited the same lines of the same file, so a person has to decide what the final code should be.
Example
You and a teammate both changed the same validation message in LoginForm. When you pull main, Git marks a conflict in that file. You read both versions, keep the correct one, and commit the resolution.
What a Conflict Looks Like
Git adds markers inside the file:
- <<<<<<< HEAD starts your version.
- ======= separates the two versions.
- >>>>>>> branch-name ends the other version.
Your job is to edit the file into the correct final code and remove all three markers. Most IDEs show this side by side with buttons to accept either change or both.
Resolving a Conflict Step by Step
- Run git status to see which files have conflicts.
- Open each file and understand both changes; don't just pick yours.
- Edit the code to the correct final version and remove the markers.
- Build and run the tests.
- Stage the files with git add and complete the merge with a commit.
If you are unsure whose change is right, ask the teammate who made the other change.
How to Avoid Conflicts
- Pull and update your branch from main often.
- Keep feature branches small and short-lived.
- Avoid reformatting whole files in the same change as real edits.
- Talk to teammates when you know you are working in the same area.
Related terms
- Merge: the operation that can cause a conflict.
- Pull: pulling new changes is when many conflicts appear.
- Feature Branch: short-lived branches have fewer conflicts.
- Git: the tool that detects conflicts.
Previous term: Merge | Next term: Microsoft Azure
Related guides
- What to Do in Your First Week of an IT Internship
- Technical Interview Questions for Freshers
- DevOps Interview Questions Test
Frequently asked questions
What is a merge conflict?
A merge conflict happens when two branches change the same lines of a file, and Git can't decide automatically which version to keep.
How do I resolve a merge conflict?
Open the conflicted files, decide the correct final code, remove the conflict markers, test, then add and commit the files.
Can I cancel a merge with conflicts?
Yes. git merge --abort returns your branch to the state before the merge started.
How can I avoid merge conflicts?
Update your branch from main often, keep branches small, and coordinate with teammates working in the same files.
Explore more internship terms
The IT Internship Glossary explains 199 terms you will hear before and during your internship, with simple definitions and real examples.
Browse all 199 terms