Conflict During Rebase
A real conflict, mid-rebase — resolved one commit at a time. Then a real escape hatch when you'd rather just stop.
feature/prices needs rebasing onto master's real, newer tip — but both sides genuinely touched the same line of spice-rack.md. This is a real rebase conflict: git pauses mid-replay, on the exact commit that cannot apply cleanly, and waits.\n\nResolving it means fixing that one commit and telling git to continue replaying the rest — genuinely different from a merge conflict, where the whole operation pauses once for everything at once. This lesson also deliberately triggers a second conflict just to abort it — the real, complete escape hatch back to exactly where you started.
A Real Conflict, Mid-Replay
git rebase master
CONFLICT (content): Merge conflict in spice-rack.md
error: could not apply <hash>... Add spice rack price guide
Git paused on the exact real commit it could not replay cleanly — everything before it already applied successfully.
Resolving and Continuing, One Commit at a Time
# edit spice-rack.md to the real, final content
git add spice-rack.md
git rebase --continue
Successfully rebased and updated refs/heads/feature/prices.
Only this one commit needed fixing — if more commits were queued behind it, each would replay (and potentially conflict) in turn, one at a time.
Why One Commit at a Time
A rebase conflict is scoped to a single, specific commit being replayed — resolving it only requires reconciling that commit's own real changes against the new base, not the entire branch's history at once. This is genuinely different from a merge conflict, which reconciles two complete histories in a single pass.
The Real Escape Hatch
git rebase master # a second, real conflict appears
git rebase --abort
Genuinely returns to the exact real state before the rebase was attempted — nothing partially applied, nothing lost.
git rebase --continue
Resumes a paused rebase after a conflict is resolved and staged, replaying the remaining queued commits. Confirmed directly in this lab: after resolving and staging spice-rack.md, --continue completed the rebase with "Successfully rebased and updated refs/heads/feature/prices."
git rebase --abort
Completely cancels an in-progress rebase, returning the branch to its exact real state before the rebase began — no partial application, nothing lost. Confirmed directly in this lab: after aborting, git status showed a genuinely clean working tree and the branch's log was completely unchanged.
🌱 Create the Real Divergence
A new branch and a real, independent master commit, both touching the same file.
cd ~/team-recipes && git switch -c feature/pricescd ~/team-recipes && printf '\nSpice Rack Price Guide: budget $20-40 for a full restock.\n' >> spice-rack.mdcd ~/team-recipes && git add spice-rack.mdcd ~/team-recipes && git commit -m 'Add spice rack price guide'cd ~/team-recipes && git push -u origin feature/pricescd ~/team-recipes && git switch mastercd ~/team-recipes && printf '\nSpice Rack Price Guide: expect $15-30 depending on brand.\n' >> spice-rack.mdcd ~/team-recipes && git add spice-rack.mdcd ~/team-recipes && git commit -m 'Add rough spice rack pricing note'cd ~/team-recipes && git pushstudent@lab:~$ cd ~/team-recipes && git switch -c feature/prices Switched to a new branch 'feature/prices' student@lab:~$ cd ~/team-recipes && printf '\nSpice Rack Price Guide: budget $20-40 for a full restock.\n' >> spice-rack.md student@lab:~$ cd ~/team-recipes && git add spice-rack.md student@lab:~$ cd ~/team-recipes && git commit -m 'Add spice rack price guide' [feature/prices 433587d] Add spice rack price guide 1 file changed, 2 insertions(+) student@lab:~$ cd ~/team-recipes && git push -u origin feature/prices Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 351 bytes | 39.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git * [new branch] feature/prices -> feature/prices branch 'feature/prices' set up to track 'origin/feature/prices'. student@lab:~$ cd ~/team-recipes && git switch master Switched to branch 'master' Your branch is up to date with 'origin/master'. student@lab:~$ cd ~/team-recipes && printf '\nSpice Rack Price Guide: expect $15-30 depending on brand.\n' >> spice-rack.md student@lab:~$ cd ~/team-recipes && git add spice-rack.md student@lab:~$ cd ~/team-recipes && git commit -m 'Add rough spice rack pricing note' [master a81ec78] Add rough spice rack pricing note 1 file changed, 2 insertions(+) student@lab:~$ cd ~/team-recipes && git push Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 356 bytes | 59.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git f99d1d6..a81ec78 master -> master
⚡ Rebase, Hit the Real Conflict, Resolve, and Continue
Rebase onto master's new tip, resolve the one conflicting commit, and let the rest replay.
cd ~/team-recipes && git switch feature/pricescd ~/team-recipes && git rebase mastercd ~/team-recipes && printf 'Spice Rack\n\nOrganize spices alphabetically for quick access.\n\nReplace ground spices every 12 months for best flavor.\n\nSpice Rack Price Guide: expect $15-40 depending on brand and restock size.\n' > spice-rack.mdcd ~/team-recipes && git add spice-rack.mdcd ~/team-recipes && git rebase --continuestudent@lab:~$ cd ~/team-recipes && git switch feature/prices Switched to branch 'feature/prices' Your branch is up to date with 'origin/feature/prices'. student@lab:~$ cd ~/team-recipes && git rebase master Auto-merging spice-rack.md CONFLICT (content): Merge conflict in spice-rack.md error: could not apply 433587d... Add spice rack price guide hint: Resolve all conflicts manually, mark them as resolved with hint: "git add/rm <conflicted_files>", then run "git rebase --continue". hint: You can instead skip this commit: run "git rebase --skip". hint: To abort and get back to the state before "git rebase", run "git rebase --abort". Could not apply 433587d... Add spice rack price guide student@lab:~$ cd ~/team-recipes && printf 'Spice Rack\n\nOrganize spices alphabetically for quick access.\n\nReplace ground spices every 12 months for best flavor.\n\nSpice Rack Price Guide: expect $15-40 depending on brand and restock size.\n' > spice-rack.md student@lab:~$ cd ~/team-recipes && git add spice-rack.md student@lab:~$ cd ~/team-recipes && git rebase --continue [detached HEAD 2f9dd7a] Add spice rack price guide 1 file changed, 1 insertion(+), 1 deletion(-) Successfully rebased and updated refs/heads/feature/prices.
📤 Push the Rebased Branch
The commit was genuinely rewritten by the rebase — push needs a real acknowledgement of that.
cd ~/team-recipes && git push --force-with-leasecd ~/team-recipes && git log --oneline -3student@lab:~$ cd ~/team-recipes && git push --force-with-lease Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 337 bytes | 67.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git + 433587d...2f9dd7a feature/prices -> feature/prices (forced update) student@lab:~$ cd ~/team-recipes && git log --oneline -3 2f9dd7a (HEAD -> feature/prices, origin/feature/prices) Add spice rack price guide a81ec78 (origin/master, origin/HEAD, master) Add rough spice rack pricing note f99d1d6 Merge pull request: weekly shopping list
🚪 Trigger a Second Conflict, and Abort It Entirely
Master moves again — rebase once more, but this time, decide to just stop.
cd ~/team-recipes && git switch mastercd ~/team-recipes && printf '\nExtra master-side spice note.\n' >> spice-rack.mdcd ~/team-recipes && git add spice-rack.mdcd ~/team-recipes && git commit -m 'Add extra spice note on master'cd ~/team-recipes && git pushcd ~/team-recipes && git switch feature/pricescd ~/team-recipes && git rebase mastercd ~/team-recipes && git rebase --abortcd ~/team-recipes && git statuscd ~/team-recipes && git log --oneline -1student@lab:~$ cd ~/team-recipes && git switch master Switched to branch 'master' Your branch is up to date with 'origin/master'. student@lab:~$ cd ~/team-recipes && printf '\nExtra master-side spice note.\n' >> spice-rack.md student@lab:~$ cd ~/team-recipes && git add spice-rack.md student@lab:~$ cd ~/team-recipes && git commit -m 'Add extra spice note on master' [master 9bc6bde] Add extra spice note on master 1 file changed, 2 insertions(+) student@lab:~$ cd ~/team-recipes && git push Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 325 bytes | 65.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git a81ec78..9bc6bde master -> master student@lab:~$ cd ~/team-recipes && git switch feature/prices Switched to branch 'feature/prices' Your branch is up to date with 'origin/feature/prices'. student@lab:~$ cd ~/team-recipes && git rebase master Auto-merging spice-rack.md CONFLICT (content): Merge conflict in spice-rack.md error: could not apply 2f9dd7a... Add spice rack price guide hint: Resolve all conflicts manually, mark them as resolved with hint: "git add/rm <conflicted_files>", then run "git rebase --continue". hint: You can instead skip this commit: run "git rebase --skip". hint: To abort and get back to the state before "git rebase", run "git rebase --abort". Could not apply 2f9dd7a... Add spice rack price guide student@lab:~$ cd ~/team-recipes && git rebase --abort student@lab:~$ cd ~/team-recipes && git status On branch feature/prices Your branch is up to date with 'origin/feature/prices'. nothing to commit, working tree clean student@lab:~$ cd ~/team-recipes && git log --oneline -1 2f9dd7a (HEAD -> feature/prices, origin/feature/prices) Add spice rack price guide
Lab 2.4.4 complete. A real rebase conflict, resolved commit-by-commit — and a real, complete escape hatch:\n\n\n Rebase conflict triggered : ✅ real, on one commit\n Resolved and continued : ✅ rest replayed cleanly\n Force-pushed the real rewrite : ✅ new hash confirmed\n Second conflict aborted : ✅ fully, cleanly reverted\n
Enable JavaScript to run the live terminal and track your progress.