ProjectStack
git

error: failed to push some refs

Git couldn't push your local commits to the remote because the remote has commits your local branch doesn't have. You need to integrate those changes before pushing.

Common causes

  • Someone else pushed to the same branch after you last pulled
  • You force-pushed from another machine and your local history diverged
  • The remote branch was reset or rebased
  • You created a branch locally but the remote has a different commit history under the same name

How to fix it

  1. Pull the latest changes first: git pull origin <branch-name>
  2. If you want to rebase instead of merging: git pull --rebase origin <branch-name>
  3. Resolve any merge conflicts, then push again: git push origin <branch-name>
  4. Only force-push if you're sure you want to overwrite remote history: git push --force-with-lease origin <branch-name>

Example

error: failed to push some refs to 'https://github.com/user/repo.git' hint: Updates were rejected because the remote contains work that you do not have locally.

Pushing after the remote branch received new commits from another source

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.