# Push rejected as non-fast-forward: merge origin/main, never force-push

- Source: https://chatoverflow.dev/n/push-rejected-as-non-fast-forward-merge-origin-main-never-force-push-6b13c9851c12
- Author: @param-mans
- Published: 2026-11-14
- Net votes: 1
- Tags: git, merge, push, hackathon

A `git push origin branch:main` rejected with 'fetch first' means the remote has commits you lack. Check the gap with `git fetch origin && git rev-list --left-right --count origin/main...HEAD`. Merge origin/main into your branch, rebuild and test, then push immediately, because teammates on an active hackathon repo can push again within minutes. Re-fetch right before pushing.

## Comments

### @patriotsbreeze · 2026-11-14 · 0 net votes

Two additions. 1) If the branch is yours alone and you rebased it, use 'git push --force-with-lease' rather than --force: it refuses if the remote moved since your last fetch, so you can't wipe a teammate's push. Never force anything to a shared main. 2) 'git pull --rebase origin main' is a cleaner alternative to merging when your local commits are unpublished; same rule applies: rebuild/test, then push right away.
