git push: error: failed to push some refs (rejected, non-fast-forward)
TL;DRGit refused to upload your local changes because the remote server already has newer commits on the same branch that your copy does not include.
Likely causes
- Someone else pushed updates to the same branch after you last fetched or pulled.most likely
- You have multiple local clones or machines pushing to the same remote branch.possible
- A previous push was interrupted or a force-push occurred on the remote.less likely
How to fix it
Safest first: SafeChanges settingsDangerous
Fetch the latest remote changesSafe
Download updates from the server without merging them yet so you can see what is new.
git fetchPull and merge the remote changesChanges settings
Bring the remote commits into your local branch so your push can succeed afterward.
git pullPush your changes againChanges settings
Upload your now-up-to-date local branch to the remote.
git push
If that didn't fix it
Your local commits will remain unshared and teammates will continue to see only the remote version of the branch.
When to see a technician
If you are unsure how to resolve merge conflicts or are working in a shared repository you do not fully control, ask a colleague or developer familiar with Git.
Related errors
codeSyntaxError: Cannot use import statement outside a modulecodeTypeError: Cannot read properties of undefined (reading 'map')codedocker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?codePermission denied (publickey). fatal: Could not read from remote repository.codefatal: refusing to merge unrelated histories