force push
A push that makes the remote branch match yours even when that throws away commits the remote has.
It overwrites commits other people pushed to the branch.
In more detail
It is needed after rewriting history you had already pushed, and it silently deletes anyone else's work that was pushed in the meantime. Prefer --force-with-lease, and never force-push a shared branch others build on.
Example
git push --force origin mainRelated terms
- commit history — The full chain of commits in a repository, which keeps every past version of every file, including deleted secrets.
- key rotation — Replacing a password or key with a new one on a schedule or after a suspected leak, and re-encrypting what it protected.
- --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.
- rewriting history — Replacing existing commits with new ones, for example with amend, rebase or reset, which gives them new IDs.
- git push — The command that uploads your commits to a remote and moves the remote's branch to match.
Taught in
- Two Ways Back From 2.5: Rollback The GitOps Way — Certified GitOps Associate (CGOA) Exam Prep
- Someone Cleaned Up The History: Versioned And Immutable — Certified GitOps Associate (CGOA) Exam Prep
- Thursday, With A Way Back: Promotion, Deploy And Release — Certified GitOps Associate (CGOA) Exam Prep
- Patterns Sprint: Eight Needs, One Pattern Each — Certified GitOps Associate (CGOA) Exam Prep
- A Bucket Nobody Wrote Down: State Stores Beyond Git — Certified GitOps Associate (CGOA) Exam Prep
- Amend, And The One Hard Rule — Advanced Git Internals & Distributed Workflows
- Secret Scanning — Application Security & Threat Modeling for Engineers