Erik Fredericks, frederer@gvsu.edu Fall 2025
Based on material provided by Erin Carrier, Austin Ferguson, and Katherine Bowers
Merge conflict: when two commits compete
Manually edit files and decide which to keep
Markers indicate who did what
<<<<<<<
=======
>>>>>>>
Though, hard to read!
Add
git commit
Q1: What if I just want to keep one version or the other, is there a better way?
git restore --ours filename
git restore --theirs filename
restore
checkout
ours
theirs
Q2: I screwed up the merge - can I start over?
git merge --abort
Q3: This is awful - is there another way?
c/o reddit: https://www.reddit.com/r/git/comments/b3wm1j/how_to_best_intentionally_create_a_merge_conflict/
git init echo 'Mr. Foo' > foo.txt git add . git commit -m 'foo' echo 'Mr. Bar' > foo.txt git add . git commit -m 'bar' # Branch from HEAD~1 - a.k.a. 1 commit ago. git checkout HEAD~1 git checkout -b branch echo 'Mr. Baz' > foo.txt git add . git commit -m 'baz' git checkout master git merge branch
git log --all --date-order --graph
clean up, then add and commit