Git push rejected (non-fast-forward): preserve remote history
A non-fast-forward rejection is a safety check: fetch and compare the local and remote tips, then merge or rebase under the repository's policy before pushing.
Scope: Git 2.x branch push rules. The remote tip may contain commits your local branch does not contain, or local amend/rebase may have rewritten already published history. The rejection prevents remote commits from being lost.
Fetch first, compare both tips and their merge base, and choose the collaboration policy: merge the remote work or rebase local commits onto it. Resolve conflicts, run the relevant tests, and push the resulting fast-forward history. If a coordinated public-history rewrite is truly intended, an explicit --force-with-lease=<ref>:<expected> is safer than unconditional force because it checks the remote tip you expect. Even an implicit lease can be weakened when a background fetch updates remote-tracking refs.
Do not automatically loop force pushes, discard local changes with reset --hard, or treat branch protection and server hooks as errors to bypass.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Git Documentation — git-push / push rules and fast-forwards ↗Revision 49204085d257 · GPL-2.0-only and attribution · reviewed snapshot SHA-256 (raw upstream page not redistributed)