How to Merge Conflicts in Git

When you’re coding with other people on a team, you typically work on different sections of a codebase. You’ll focus on one feature, and your coworker or teammate will focus on another feature.

This is why Git is a really useful tool—because Git allows people to work in what are called branches. You can work in one branch, your teammate can work in another branch, and you can each work on your separate files or lines of code. Then, Git is able to merge those branches together into one main branch.

Now, this final version of the codebase has both your teammate’s changes and your changes.

However, there are times when you and your teammate modify the same lines of code. This is called a merge conflict. A merge conflict happens when Git tries to merge two versions of code (or branches) together but finds conflicting changes.

So, how do we resolve merge conflicts? Git requires humans—the developers—to resolve these conflicts manually.

In this video, I’m going to talk about three scenarios where you might encounter merge conflicts. I’m going to go through one example where we have a merge conflict between two developers. Then, I’ll go over two main ways to resolve the merge conflict.

Thank you for watching, and happy coding! 💻
-Henrik

Leave a Reply

Your email address will not be published. Required fields are marked *