← Back to all fixes
Branches have diverged — push rejected
The Issue
`git push` fails: `rejected — non-fast-forward: Updates were rejected because the remote contains work that you do not have locally`
Root Cause
Someone else pushed to the same branch, or you pushed from another machine. Your local branch is behind the remote.
How to Fix
Pull first: `git pull --rebase origin main` (rebase keeps history linear)Or: `git pull origin main` (creates a merge commit)Resolve any conflicts that arise, then push againDo NOT use `git push --force` unless you are the only one on that branch — it overwrites others' workUse `--force-with-lease` if you must force push: safer, fails if someone else pushed