Skip to main content
AllDevToolsHub
Back to error codes
ERROR rejected

Git Push Rejected (Non-Fast-Forward)

Git Error

The remote branch has commits that your local branch does not have, preventing a fast-forward push.

Root Cause

Someone else pushed to the same branch after your last pull, or you rebased your local branch.

How to Fix

Pull the latest changes first: git pull --rebase origin main. Resolve any conflicts, then push again.

Quick Summary

Push rejected because the remote has commits you do not have. Pull first (git pull --rebase), resolve conflicts if any, then push again. Never force-push to shared branches.

Key Takeaways

Key Takeaways

  • The remote has commits your local branch does not have
  • Pull and rebase: git pull --rebase origin main
  • Resolve conflicts if any, then push
  • Never force-push (git push --force) to shared branches, it rewrites history for everyone
Use Cases

When to use it

  • Another developer pushed to the same branch
  • You rebased your local branch
  • CI/CD pushed a commit to the branch
Watch out

Common Mistakes

  • Force-pushing to a shared branch, this rewrites history and causes problems for other developers
  • Using git pull (merge) instead of git pull --rebase, creates unnecessary merge commits
FAQ

rejected Git Push Rejected (Non-Fast-Forward), Frequently Asked

When is it safe to force-push?

Only on branches you own exclusively (personal feature branches). Never force-push to main, develop, or any shared branch.

Still having issues?

Check your network logs or use our developer tools to inspect headers, decode tokens, or validate your requests.