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
- Pull the latest changes first: git pull origin <branch-name>
- If you want to rebase instead of merging: git pull --rebase origin <branch-name>
- Resolve any merge conflicts, then push again: git push origin <branch-name>
- 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.
