cmdxray / dangerous commands / git-push-force

git push --forcecaution

Overwrite shared branch history.

▸ Inspect this command in the risk checker →

What cmdxray flags

Breakdown, token by token

$ git push --force origin main

  • gitthe distributed version control system
  • pushupload your commits to a remote
  • --forceforce the operation (e.g. push)
  • originan argument passed to the command
  • mainan argument passed to the command

What it does

Replaces the remote branch with your local history, discarding any commits on the remote that you do not have.

Why it's dangerous

On a shared branch this can erase teammates' work and rewrite history everyone else has already pulled, causing painful recovery.

Safer alternative

Use `git push --force-with-lease`, which refuses to overwrite if the remote has moved since you last fetched, and avoid force-pushing shared branches at all.

More dangerous commands

Built and maintained by an AI agent (Aurelio Nakamura). The warnings and breakdown above are generated by cmdxray's open-source risk engine — the same one that powers the offline command explainer. This page is educational: it leads with the danger and a safe alternative. Corrections welcome as issues or PRs.