Conflicts
Branching & Merging
Preview
Merge conflicts
When two branches edit the same lines differently, Git cannot decide for you. It marks the file and asks you to choose.
The conflict markers
<<<<<<< HEAD\nconsole.log("v1");\n=======\nconsole.log("v2");\n>>>>>>> featureResolving
- Open the conflicted file
- Choose one side, both, or a new version
- Delete the
<<<<<<<markers git add file.txtgit committo finish the merge
Prevent conflicts
- Pull/merge from main into your branch often
- Keep changes small and focused
- Communicate who owns which files
- Merge branches quickly, don't let them age
In an editor
VS Code shows conflicting blocks with "Accept Current / Accept Incoming / Accept Both" buttons — point and click, then commit.
Conflicts are normal
Everyone hits them. A clean resolution is part of the job — not a failure.
Tip: The longer a branch lives, the bigger the conflicts. Merge early, merge often.
This is a free preview lesson
Enroll in the Git & GitHub for Beginners to unlock every lesson, lesson PDF guides, quizzes and your certificate - and start creating your own pieces today.