Lessons · Git · reading a conflict
Reading a conflict
Between <<<<<<< and ======= is where you are. Between ======= and >>>>>>> is what is arriving. The label after >>>>>>> names it.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
During a MERGE 'where you are' is your branch. During a REBASE it is the branch you are rebasing onto, and your own commit is the bottom half. That inversion is the commonest way a rebase conflict gets resolved backwards.
How to think about it
Read the labels rather than assuming. Git writes them for exactly this reason, and they are different in the two cases.
Worked example
git rebase mainIt stops. One commit could not be applied cleanly.
cat f.txtThe top half says 'the upstream' -- which is MAIN, not your work.
git status --shortUU: unmerged, changed on both sides.
git show :2:f.txtStage 2, what git calls ours: the upstream, during a rebase.
git show :3:f.txtStage 3, theirs: your own commit. This is the inversion.
git rebase --abortAnd out, with nothing changed.
Your turn
Show the version of the file from the side being applied.
git show :f.txt
Try it in a real repository
The trap
Reaching for --ours during a rebase because you want to keep your work. Ours is the upstream there, and your work is theirs.