Hone

Lessons · Git · the stop-resolve-continue loop

Stop, resolve, continue

A rebase replays your commits one at a time, so it can stop once per commit. Staging the resolved file is what tells git you are done with this one.

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

People expect one conflict per rebase and get several, conclude something is wrong, and abort work that was going fine.

How to think about it

Resolve, git add, git rebase --continue. Repeat until it says it has finished. Editing the file is not enough: git cannot see an edit, only the index.

Worked example

git rebase main
It stops on the first commit it cannot apply.
echo resolved > f.txt
You decide what the file should say.
git status --short
Still UU. Editing the file changed nothing git can see, so --continue here is refused.
git add f.txt
THIS is the signal.
git status --short
M now, not UU: the path is no longer unmerged.
git rebase --continue
And it finishes.
git log --oneline
Three commits, in a straight line.

Your turn

Tell git the conflict in f.txt is resolved.

git  f.txt

The trap

Expecting one stop. A ten-commit branch can stop ten times, and often on the same lines, because your later commits touch what your earlier ones changed.

Practise the stop-resolve-continue loop on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.