CodeOath
← All posts
Git65 min total · 17 parts

Git Internals and Workflows: Branching, Merging, and Rebasing

Contents — Part 8 of 17: Resolving a Rebase Conflict
Part 8 of 17 · ~1 min

Resolving a Rebase Conflict

A rebase can conflict too — for the same underlying reason (two changes touching the same lines), but the recovery commands are different because a rebase is really a sequence of individual commit replays, one at a time, and it can pause on any of them:

git rebase main
# ... conflict on the 2nd commit being replayed ...
# edit the conflicting file(s) to the resolved version
git add <the resolved file>
git rebase --continue    # applies the rest of the rebase's remaining commits

Two other options exist specifically for a rebase in progress that a plain merge conflict doesn't have, because a merge is one atomic operation while a rebase is several:

git rebase --abort   # cancel the whole rebase, returning to exactly how things were before it started
git rebase --skip    # skip this one commit entirely, discarding its changes, and continue with the rest

--abort is the right move whenever a rebase turns out to be more trouble than it's worth partway through — it's fully safe and puts you back exactly where you were, with zero risk of a half-finished rebase corrupting anything.