GitHub Push Rejected: Updates Were Rejected (Non-Fast-Forward)
Quick answer
GitHub rejected your push because the remote branch has commits you do not have locally. Fetch and integrate them (git pull, or pull --rebase), then push again. Do not force-push on a shared branch.
Most likely fix: Fetch and merge the remote changes
How to fix it
Try these in order — the most common fix is first.
1. Fetch and merge the remote changes
- Run git fetch origin
- Run git merge origin/YOUR_BRANCH
- Resolve conflicts if any, commit, then git push origin YOUR_BRANCH
Did this fix it?2. Pull with rebase for a linear history
- Run git pull --rebase origin YOUR_BRANCH
- Fix conflicts, git rebase --continue, then git push
Did this fix it?3. If you rewrote your own branch on purpose, use a safe force push
- Run git push --force-with-lease origin YOUR_BRANCH
- This refuses to overwrite commits you have not seen, unlike plain --force
- Never do this on a shared protected branch
Did this fix it?4. Unrelated histories after creating a repo with a README
- Run git pull origin main --allow-unrelated-histories
- Resolve conflicts, commit and push
Did this fix it?
Symptoms
git push shows '! [rejected] main -> main (fetch first)' or '(non-fast-forward)' and 'failed to push some refs'.
Why it happens
- Someone else (or you, from another machine or the web editor) pushed to the same branch
- You amended or rebased commits that were already pushed
- The local branch was created from a different history than the remote
This guide also covers
- github updates were rejected because the remote contains work
- git push rejected non-fast-forward
- failed to push some refs github
- github push rejected fetch first
Still not working?
If GitHub keeps failing, you're not alone. See every GitHub problem users report or the alternatives people switch to.
Need a custom web app or internal tool? Our small team builds it, on your domain or hosted by us. Price agreed together.
Get a quoteOther GitHub errors
- GitHub Permission Denied (publickey) Error
- GitHub 'Password Authentication Was Removed' Error
- GitHub Push Blocked: Repository Rule Violations (GH013 / Secret Detected)
- GitHub Push Rejected: File Exceeds 100 MB Limit
- GitHub 'Permission Denied' or 403 When Pushing Over HTTPS
- GitHub Locked Out: Lost 2FA Device or Recovery Codes
- GitHub Actions Workflow Stuck in Queued / Waiting for a Runner
- GitHub Actions: 'Recent Account Payments Have Failed or Spending Limit Needs to Be Increased'