A Real, Safe Rejection
! [rejected] (fetch first)
git's real, built-in safety net: it will never silently overwrite real remote work it does not know about.
Watching --force Actually Destroy It
cp -r ~/team-recipes ~/team-recipes-danger-demo
cp -r ~/recipes-origin.git ~/recipes-origin-danger-demo.git
cd ~/team-recipes-danger-demo && git remote set-url origin ../recipes-origin-danger-demo.git
git push --force
A real, genuinely disposable copy — its own clone AND its own origin, so the real shared repository is never touched. On it: Frank's genuine commit, gone, no trace, no warning.
The Real, Safe Alternative
cd ~/team-recipes && git push --force-with-lease
! [rejected] (stale info)
Refused — because --force-with-lease genuinely checks that the remote hasn't moved since you last saw it, before ever overwriting anything.
Resolving It for Real, Then Pushing Safely
git fetch origin
git rebase origin/feature/dinner-plans
# ...a real conflict, resolved by hand...
git rebase --continue
git push --force-with-lease
Now safe and correct: local genuinely contains Frank's real commit too, so --force-with-lease has nothing real left to protect against.
feature/dinner-plans is genuinely shared — Frank Chen pushed his own real commit to it while you were working locally, completely unaware. Your own local history has since moved too. A plain push gets genuinely rejected — git's real, built-in safety net catching exactly this situation.
This lesson shows, live, on a disposable throwaway clone, exactly what plain --force would actually do: genuinely destroy Frank's real commit, no warning, no trace. Then it shows the real, safe alternative — --force-with-lease — correctly refusing the exact same push, because it can see the remote has moved since you last looked.
git push --force
Genuinely overwrites the remote branch with local history, no matter what real work is already there — confirmed directly in this lab actually destroying a real teammate's commit on a disposable clone, with zero warning.
git push --force-with-lease
Only overwrites the remote if it still genuinely matches what your local repository last saw — confirmed directly in this lab refusing the exact same push once the remote had real, new work it didn't know about.
Takeaways
- A plain git push genuinely refuses to overwrite remote work your local repository does not have — a real, built-in safety net
- git push --force overwrites the remote unconditionally — confirmed directly destroying a real teammate's commit with zero warning
- git push --force-with-lease checks that the remote still matches what you last saw before ever overwriting anything
- The real, safe recovery from a shared-branch conflict is fetch, integrate for real, then force-with-lease — never blind --force