Best PracticesLesson 9 of 10
Handling Merge Conflicts
2 min readGitHub for Designers
Merge conflicts happen when two people edit the same part of a file. They're normal and not scary once you understand how to resolve them.
Why Conflicts Happen
Git is smart about merging changes, but it can't decide when two people modify the same lines. You need to tell Git which changes to keep.
What a Conflict Looks Like
Conflict markers in file
<<<<<<< HEAD
Your changes here
=======
Their changes here
>>>>>>> feature-branchResolving Conflicts
1
Identify Conflicted Files
Git will tell you which files have conflicts. Look for files marked as "both modified".
2
Edit the File
- Open the conflicted file
- Find the conflict markers (<<<<<<, =======, >>>>>>)
- Decide which changes to keep (or combine both)
- Remove the conflict markers
3
Save and Commit
After resolving, stage the file and commit:
Terminal
git add resolved-file.css
git commit -m "Resolve merge conflict in styles"Use Visual Tools
VS Code and GitHub Desktop have built-in merge conflict resolvers that make this process much easier. They show changes side-by-side and let you click to choose which version to keep.
Lesson Complete!
- Understand why conflicts happen
- Recognize conflict markers
- Resolve conflicts manually or with tools
Conflicts are no longer scary!