dev@local: ~/project — git
dev@local~/project$git push origin main
To github.com:developer/project.git
! [rejected] main -> main (fetch first)
error: failed to push some refs
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
Diagnostics Translation
Git rejected your push because the remote repository contains commits missing from your local branch.
waiting for resolution...
MediumVersion Control System

Reviewed for reference consistency: April 11, 2026

Code is Safe

SECURE

Git has paused the operation to protect your code. No data has been lost or corrupted.

What To Know

This is a broad push-rejection wrapper: Git reached the remote, but the branch relationship or remote policy did not allow the update to land.

Where Did It Fail?

Working Tree
Your local files
add
Staging Index
Prepared changes
commit
Local Repo
Commit history
push/fetch
Remote Server
GitHub/GitLab
The error occurred during a network exchange. Your local files are untouched, but Git cannot reach the remote server.

Commands That Trigger This

$git push origin main
Running after a coworker already pushed their changes to `main`
$git rebase
Trying to push after rewriting history with

Technical Background

01

Git enforces a strict timeline. If the remote branch has progressed, your local history must first be reconciled with that newer remote state before the push can land.

02

This mechanism ensures that collaborative work is never accidentally erased by someone with an outdated local copy.

Underlying Causes

Another developer pushed changes to the same remote branch
You amended or rebased local commits that were already pushed
A CI/CD pipeline added an automated commit to the remote branch

Frequently Asked Questions

Only if you are absolutely sure you want to erase the remote commits. In most collaborative scenarios, you should pull and merge instead.

Related Git States