Skip to main content
⚡ OpenDevDocs
Git
gitgitTroubleshootingBeginner

Updates were rejected: non-fast-forward push

Safely resolve Git rejected push errors by rebasing and reconciling divergent remote history without data loss.

Verified: 2026-09-30
Tested on:git 2.44+
Platforms:
all
#git#push#rebase#non-fast-forward

Error Message

To https://github.com/iamtashanto/OpenDevDocs.git
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/iamtashanto/OpenDevDocs.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Symptoms

  • git push origin <branch> fails with [rejected] (non-fast-forward).
  • Git warns that the tip of your local branch is behind the remote counterpart.

Why It Happens

Git prevents you from overwriting commits on the remote branch that you do not have locally in your commit history. This happens when:

  1. A teammate pushed new commits to the remote branch while you were working.
  2. A PR was merged on GitHub directly into the branch.
  3. You previously amended or rebased local commits that were already pushed.

Fetch the remote commits and replay your local commits on top using Rebase:

# 1. Fetch remote changes and rebase your commits on top
git pull --rebase origin main

# 2. Push your rebased branch cleanly
git push origin main

Step-by-Step Resolution


What NOT to Do: Dangerous Force Pushing

On this page