How to Resolve Merge Conflicts in Git

Prabhu TL
6 Min Read
Disclosure: This website may contain affiliate links, which means I may earn a commission if you click on the link and make a purchase. I only recommend products or services that I personally use and believe will add value to my readers. Your support is appreciated!
How to Resolve Merge Conflicts in Git featured image

Merge conflicts look scary the first time you hit them, but they are not a disaster. A conflict simply means Git needs human help deciding which changes should win because two sets of edits overlap in a way Git cannot safely combine on its own.

Key Takeaways

  • A merge conflict means Git found overlapping edits it could not auto-merge.
  • The usual fix is to inspect the file, choose the correct final content, then stage and commit the resolved version.
  • Reading conflict markers carefully is the key skill.
  • Small focused branches and frequent pulls reduce the chance of painful conflicts.

What a Merge Conflict Really Means

A conflict usually happens when two branches changed the same lines, or when one side changed a file that the other side deleted. Git pauses and asks you to decide what the final file should look like. That pause is useful: it prevents Git from guessing wrong and silently damaging the codebase.

How to Resolve Conflicts Step by Step

  1. Run the merge or pull command that triggers the conflict.
  2. Use git status to see which files are conflicted.
  3. Open each conflicted file in your editor.
  4. Look for the conflict markers and decide which content to keep.
  5. Edit the file into its correct final form and remove the markers.
  6. Stage the resolved file with git add <file>.
  7. Once all conflicts are resolved, create the merge commit (or continue the rebase if you were rebasing).
CommandWhy you use itTypical moment
git statusShows conflicted files and next steps.Immediately after Git reports a conflict.
git add <file>Marks a file as resolved after editing.After you clean up each conflict.
git commitCompletes the merge commit if Git has not auto-created it.When all conflicts are resolved.
git rebase --continueContinues a rebase after resolving a conflict.Only during a rebase workflow.
git merge --abortBacks out of the merge if you want to stop.When you decide not to continue the merge.

Understanding Conflict Markers

MarkerMeaningWhat to do
<<<<<<< HEADYour current branch’s version.Review it carefully.
=======Separator between two versions.Use it as the split point.
>>>>>>> other-branchIncoming branch’s version.Compare it against your version.

Your job is to replace the marked block with the final content you actually want to keep. That might be one side, the other side, or a combination of both.

Useful Resource: Explore Our Powerful Digital Product Bundles

Browse these high-value bundles for website creators, developers, designers, startups, content creators, and digital product sellers.

Explore Our Powerful Digital Product Bundles

How to Prevent Future Conflicts

  • Pull more often instead of working for long periods without syncing.
  • Keep branches focused and short-lived.
  • Avoid giant commits that touch many unrelated files.
  • Communicate with collaborators about files likely to overlap.
  • Use clearer branch boundaries—for example, one branch for navigation, another for payment fixes.

Useful Resources

Further Reading

FAQs

Should I panic when I see a merge conflict?
No. A conflict is Git asking for a decision, not telling you that work is lost. Read the file carefully and resolve it step by step.
Can GitHub resolve all merge conflicts in the browser?
No. Simple line conflicts can often be resolved on GitHub, but many conflicts still need local resolution in your editor and terminal.
What if I picked the wrong version while resolving?
Before committing, you can edit again. After committing, you can still create a follow-up commit or use Git history to recover.

Final Thoughts

Merge conflicts become much less stressful once you recognize the pattern: inspect, decide, clean up, stage, continue. The more disciplined your branch workflow becomes, the less dramatic conflicts feel—and the faster you resolve them when they do appear.

References

  1. GitHub guide to resolving a merge conflict using the command line
  2. GitHub Docs
  3. Git reference
  4. Atlassian merging vs rebasing

Keyword tags: resolve merge conflicts, git merge conflict, how to fix merge conflicts, git conflict markers, git merge tutorial, conflict resolution in git, git pull conflict, git status conflict, merge conflict guide, git troubleshooting, fix code conflicts, git conflict tips

Share This Article
Prabhu TL is a SenseCentral contributor covering digital products, entrepreneurship, and scalable online business systems. He focuses on turning ideas into repeatable processes—validation, positioning, marketing, and execution. His writing is known for simple frameworks, clear checklists, and real-world examples. When he’s not writing, he’s usually building new digital assets and experimenting with growth channels.