Sentry Answers>Git>

Git "failed to push some refs to remote"

Git "failed to push some refs to remote"

David Y.

The ProblemJump To Solution

When attempting to push local commits to a remote repository, I receive the following error:

Click to Copy
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '' 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.

How do I resolve this error and push my changes?

The Solution

This error generally occurs if new commits have been pushed to the repository since our last pull. For example, let’s say that Alice and Bob both pull the repository at commit A. Alice makes changes and creates commit B, which she then pushes. Bob also makes changes, creating commit C, but when he tries to push this commit, he receives the error above because his repository history does not contain Alice’s commit B.

To fix this, Bob must pull Alice’s changes and integrate them into his repository’s history. He can do this using the following git pull command:

Click to Copy
git pull --rebase

The --rebase flag will tell git pull to fetch the upstream version of the current branch (i.e. the one with commits A and B) and replay the changes made in commit C on top of it.

Once this is done, Bob can run git push again.

  • ResourcesWhat is Distributed Tracing
  • logo
    Listen to the Syntax Podcast

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.


Loved by over 4 million developers and more than 90,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.

© 2024 • Sentry is a registered Trademark
of Functional Software, Inc.