--force-with-lease

A safer force push that only overwrites the remote branch if it still points where your remote-tracking branch says it does.

It still rewrites the shared branch, only with a check that you are not overwriting unseen work.

In more detail

If someone pushed after your last fetch, the lease no longer matches and the push is refused, so you do not destroy work you have not seen. Fetching right before pushing defeats that protection, because your record then matches again.

Example

git push --force-with-lease origin main

Related terms

Taught in

References