Gitflow
🌀Teammate Pushed While You Were RebasingHard+750 XP
Scenario reference

Teammate Pushed While You Were Rebasing: the situation, step by step

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:

  1. 01Start the rebase onto main (it stops on a conflict)
  2. 02See which file conflicts
  3. 03Edit checkout.js to remove the conflict markers
  4. 04Stage the resolved file
  5. 05Finish the rebase
  6. 06Fetch the commits your collaborator pushed meanwhile
  7. 07Try force-with-lease (it refuses — their work would vanish)
  8. 08Pull with rebase to replay your work on top of theirs
  9. 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. 1. Start the rebase onto main (it stops on a conflict)
    git rebase main
  2. 2. See which file conflicts
    git status
  3. 3. Edit checkout.js to remove the conflict markers
    echo "// checkout: both changes merged" > checkout.js
  4. 4. Stage the resolved file
    git add .
  5. 5. Finish the rebase
    git rebase --continue
  6. 6. Fetch the commits your collaborator pushed meanwhile
    git fetch origin
  7. 7. Try force-with-lease (it refuses — their work would vanish)
    git push --force-with-lease
  8. 8. Pull with rebase to replay your work on top of theirs
    git pull --rebase
  9. 9. Now safely force push
    git push --force-with-lease

Key takeaway

Communicate before rebasing shared branches. Pull-rebase loops handle the rest.