The situation
Mid-rebase, your phone buzzes: a collaborator pushed 2 commits to the same feature branch. You're about to overwrite their work.
Your rebase conflicts on checkout.js. Finish it, fetch their work, integrate before push — force-with-lease will refuse until you do.
Hard · 9 steps · +750 XP
What you will practice
This scenario walks through 9 steps, in order:
- 01Start the rebase onto main (it stops on a conflict)
- 02See which file conflicts
- 03Edit checkout.js to remove the conflict markers
- 04Stage the resolved file
- 05Finish the rebase
- 06Fetch the commits your collaborator pushed meanwhile
- 07Try force-with-lease (it refuses — their work would vanish)
- 08Pull with rebase to replay your work on top of theirs
- 09Now safely force push
Reveal the step-by-step commands
Try the terminal first — you learn more by doing. When you want to check yourself, here is the command for each step.
1. Start the rebase onto main (it stops on a conflict)
git rebase main2. See which file conflicts
git status3. Edit checkout.js to remove the conflict markers
echo "// checkout: both changes merged" > checkout.js4. Stage the resolved file
git add .5. Finish the rebase
git rebase --continue6. Fetch the commits your collaborator pushed meanwhile
git fetch origin7. Try force-with-lease (it refuses — their work would vanish)
git push --force-with-lease8. Pull with rebase to replay your work on top of theirs
git pull --rebase9. Now safely force push
git push --force-with-lease
Key takeaway
Communicate before rebasing shared branches. Pull-rebase loops handle the rest.