Skip to content
Remotes

Force-pushing

What it costs somebody else, and the flag that checks first.

A normal push is refused unless it is a fast-forward, because anything else would remove commits from the remote that somebody may already have.

`--force` overwrites regardless. If a colleague pushed in between, their commits are no longer referenced on the remote, and unless they still have them locally they are gone.

`--force-with-lease` does the same thing but only while the remote is still where your remote-tracking branch says it is. If somebody has pushed since you last fetched, it refuses. It costs nothing and removes almost the entire risk.

Commands in this lesson

git push --force-with-lease
Force, but only while the remote is where you last saw it
git push --force
Send commits even if that removes some from the remote
No account, no backend. Everything you do stays in this browser.liter8.sh