Ad space (banner)
🌿Git Lessons
Lesson 50 / 59

Understanding the Danger of git push --force

This lesson covers the dangers of git push --force. It's for anyone searching "git push --force danger."

git push --force forcibly overwrites the remote repository's history with your own local history. Even in situations a normal push would refuse, because the histories don't line up, this pushes the change through anyway.

In Try It, run git push --force. The remote's history is replaced with your local content — but you need to understand just how serious this operation is before using it.

A common early mistake is using this without knowing how dangerous it is — changes that another team member has already pushed can be completely wiped out by a force push, which demands real caution in team development. In real teams, when this really is necessary, the recommendation is to use the safer --force-with-lease option instead, which checks you're not about to overwrite someone else's changes before it runs.

Git
Try it (type this into the pseudo terminal)
git push --force

🧑‍💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)