Git Merge & Conflicts

Combine branches and resolve conflicts.

✍️ 2 exercises in this lesson

To bring a branch's work into main: switch to main, then git merge feature-contact.

Merge conflicts

If both branches changed the same lines, Git cannot decide automatically. It marks the conflict in the file:

<<<<<<< HEAD
your version
=======
their version
>>>>>>> feature-contact

Edit the file to keep the correct content, remove the markers, then git add and git commit.

Key Takeaways: Git Merge & Conflicts

Mastering Git Merge & Conflicts helps you write clean and reliable Git code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

Git Merge & Conflicts Code Example

Git
git switch main
git merge feature-contact
git branch -d feature-contact
git log --oneline
Output
Updating 8c4d7e2..1a9e3c4
Fast-forward
 contact.html | 1 +
Deleted branch feature-contact (was 1a9e3c4).
1a9e3c4 (HEAD -> main) Add contact page
8c4d7e2 Add homepage
3f2a1b9 Add README
Run this example on your own computer. The "Get Started" lesson shows how to set it up.

Git Merge & Conflicts Practice Exercises

Check what you learned in “Git Merge & Conflicts”.

/ 2 solved
Fill in the blank

Merge feature-contact into the current branch.

git  feature-contact
✓ Correct! Not quite. Try again.
Multiple choice

What do <<<<<<< and >>>>>>> markers in a file mean?

✓ Correct! Not quite. Try again.
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services