Hone

Lessons · Git · knowing you have finished resolving

Knowing you have finished

Two checks: git reports no unmerged paths, and no conflict marker is left in any file. Staging a file with markers still in it is entirely possible.

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

A commit containing <<<<<<< is a real thing that happens, and it usually reaches a branch before anybody notices.

How to think about it

Look for the markers before you stage, not after. And build the project if you can: a resolution can be syntactically fine and semantically wrong.

Worked example

git merge feature
Stopped.
grep -c '<<<<<<<' f.txt
One marker. This is the check worth automating in your head.
echo both sides, properly > f.txt
Resolved by hand.
grep -c '<<<<<<<' f.txt || true
Zero. Nothing left behind.
git add f.txt
Staged.
git status --short
M, and no unmerged paths.
git commit -qm 'merge feature'
And the merge is complete.

Your turn

Count the conflict markers left in the file.

grep -c  f.txt

The trap

Trusting that the editor showed you every conflict. A long file can have several, and the last one is usually the one that gets committed.

Practise knowing you have finished resolving on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.