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

  1. Run git status to see which files have conflicts.
  2. Open each file and understand both changes; don't just pick yours.
  3. Edit the code to the correct final version and remove the markers.
  4. Build and run the tests.
  5. 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

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
Dhaivat Ajwaliya

About the author

Dhaivat Ajwaliya

Dhaivat has 16+ years of experience in the IT industry, working on AI and cloud technologies, project delivery, and engineering leadership. He has interviewed and mentored many interns, wrote The Lost Intern, and runs the non-commercial Career Impact Initiative, mentoring students for free.