Git 2 · Remotes

Force push safely

Overwrite the remote branch only if nobody has pushed to it since you last fetched.

git push --force-with-lease

Caution: Force pushing replaces remote history. Never do it on a shared branch such as main.

Official Git 2 documentation

More remotes commands

All remotes commands · Git 2 cheatsheet

Was this page helpful?