Solution / Git

git push rejected, non-fast-forward

Beginner1 min6 Dec 2026

Error! [rejected] main -> main (non-fast-forward)

You committed locally, pushed, and Git refused the update. Someone else pushed to the same branch first. Your history and the remote history have diverged.

Why it happens

A fast-forward is only possible when your branch is a straight extension of the remote branch. If the remote has a commit you never downloaded, Git will not overwrite that commit with your push.

A safe update

Git
git status
git pull --rebase origin main
git push origin main

pull --rebase replays your local commits on top of the remote ones, so you do not add a merge commit for a simple update. If Git stops on a conflict, fix the file, then run git rebase --continue. If you want to abandon the rebase, git rebase --abort returns you to the state before the pull.

  1. Run git status and confirm you are on the branch you meant to update.
  2. Fetch the remote commits with git pull --rebase.
  3. Resolve any conflicts, continue the rebase, and push again.
  4. Reserve git push --force-with-lease for a branch you alone use, after you understand which commits it will replace.

Related