Conflicts When Pulling
Same line, two people.
Conflicts don't only happen between your own branches. If you and a teammate change the same line, and they push first, your pull will stop with a conflict. Good news. You already know how to fix it.

- You and a teammate
- Same line, both changed
- Pull stops with a conflict
The conflict
Alex changed the title and pushed. We changed the same title, to our full name, and committed. Now we pull. Git fetches Alex's commit, tries to merge, and reports a conflict in index dot HTML. The file has the familiar markers. Our version, from head, and Alex's, from the commit we just fetched.
git pull From https://github.com/sam/my-site f63a17a..55e2160 main -> origin/main Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result. head -5 index.html <<<<<<< HEAD <h1>Sam Lee</h1> ======= <h1>Alex and Sam</h1> >>>>>>> 55e216046f2ee92e8af501a3a5bd62e7ebc8d991
Fix, commit, push
Exactly like before. In our editor, we choose a final title, and remove the markers. Then add, commit, and push. GitHub now has both commits, joined by our merge commit.
cat index.html <h1>Sam Lee and Alex Kim</h1> <p>Welcome!</p> <a href="about.html">About</a> git add index.html git commit --no-edit [main 74a1d13] Merge branch 'main' of https://github.com/sam/my-site git push To https://github.com/sam/my-site.git 55e2160..74a1d13 main -> main
Summary
A conflict when pulling is fixed just like any merge conflict. Edit, add, commit, then push. Next, another way to pull, that keeps history in a straight line.
Key takeaways- Conflict on pull? Same fix
- Edit, git add, git commit
- Then git push