(Note: starting Oct. 2020, any new repository is created with the default branch main, not master. And you can rename existing repository default branch from master to main.
The rest of this 2014 answer has been updated to use "main")

(The following assumes github.com itself is not down, as eri0o points out in the comments: see www.githubstatus.com to be sure)

If the GitHub repo has seen new commits pushed to it, while you were working locally, I would advise using:

git pull --rebase
git push

The full syntax is:

git pull --rebase origin main
git push origin main

With Git 2.6+ (Sept. 2015), after having done (once)

git config --global pull.rebase true
git config --global rebase.autoStash true

A simple git pull would be enough.
(Note: with Git 2.27 Q2 2020, a merge.autostash is also available for your regular pull, without rebase)

That way, you would replay (the --rebase part) your local commits on top of the newly updated origin/main (or origin/yourBranch: git pull origin yourBranch).

See a more complete example in the chapter 6 Pull with rebase of the Git Pocket Book.

I would recommend a:

# add and commit first
#
git push -u origin main

# Or git 2.37 Q2 2022+
git config --global push.autoSetupRemote true
git push

That would establish a tracking relationship between your local main branch and its upstream branch.
After that, any future push for that branch can be done with a simple:

git push

Again, with Git 2.37+ and its global option push.autoSetupRemote, a simple git push even for the first one would do the same (I.e: establishing a tracking relationship between your local main branch and its upstream branch origin/main).

See "Why do I need to explicitly push a new branch?".


Since the OP already reset and redone its commit on top of origin/main:

git reset --mixed origin/main
git add .
git commit -m "This is a new commit for what I originally planned to be amended"
git push origin main

There is no need to pull --rebase.

Note: git reset --mixed origin/main can also be written git reset origin/main, since the --mixed option is the default one when using git reset.

Answer from VonC on Stack Overflow
Top answer
1 of 16
1340

(Note: starting Oct. 2020, any new repository is created with the default branch main, not master. And you can rename existing repository default branch from master to main.
The rest of this 2014 answer has been updated to use "main")

(The following assumes github.com itself is not down, as eri0o points out in the comments: see www.githubstatus.com to be sure)

If the GitHub repo has seen new commits pushed to it, while you were working locally, I would advise using:

git pull --rebase
git push

The full syntax is:

git pull --rebase origin main
git push origin main

With Git 2.6+ (Sept. 2015), after having done (once)

git config --global pull.rebase true
git config --global rebase.autoStash true

A simple git pull would be enough.
(Note: with Git 2.27 Q2 2020, a merge.autostash is also available for your regular pull, without rebase)

That way, you would replay (the --rebase part) your local commits on top of the newly updated origin/main (or origin/yourBranch: git pull origin yourBranch).

See a more complete example in the chapter 6 Pull with rebase of the Git Pocket Book.

I would recommend a:

# add and commit first
#
git push -u origin main

# Or git 2.37 Q2 2022+
git config --global push.autoSetupRemote true
git push

That would establish a tracking relationship between your local main branch and its upstream branch.
After that, any future push for that branch can be done with a simple:

git push

Again, with Git 2.37+ and its global option push.autoSetupRemote, a simple git push even for the first one would do the same (I.e: establishing a tracking relationship between your local main branch and its upstream branch origin/main).

See "Why do I need to explicitly push a new branch?".


Since the OP already reset and redone its commit on top of origin/main:

git reset --mixed origin/main
git add .
git commit -m "This is a new commit for what I originally planned to be amended"
git push origin main

There is no need to pull --rebase.

Note: git reset --mixed origin/main can also be written git reset origin/main, since the --mixed option is the default one when using git reset.

2 of 16
271

Try:

git push -f origin master

That should solve the problem.

Based on Mehdi‘s comment, a clarification about -force pushing: The Git command above works safely only for the first commit. If there were already commits, pull requests or branches in previous, this resets all of it and set it from zero. If so, please refer to VonC‘s detailed answer for a better solution.

🌐
Komodor
komodor.com › home › articles › how to fix ‘failed to push some refs to’ git errors
Git Error: 'failed to push some refs to': Steps to Fix
September 15, 2025 - If you got a master (fetch first) error with a failed to push some refs to error, this means someone has pushed to the branch before you. Git wants you to pull first before you can push your committed changes.
Discussions

Can't force push a ref to a remote if local repo doesn't have the commit referred to by the current remote ref
Describe the bug This is a corner case, but one I've run into frequently over the last few days. When trying to force push, if the local repository doesn't contain the commit that the remote has for the ref being pushed, LFS causes an error and the push fails. More on github.com
🌐 github.com
2
May 20, 2020
git push rejected: error: failed to push some refs - Stack Overflow
I know people have asked similar questions, but I believe the causes of their problems to be different. I did a hard reset because I had messed up my code pretty bad git reset --hard 41651df8fc9... More on stackoverflow.com
🌐 stackoverflow.com
July 29, 2016
Github: Failed to push some refs to ...
That's exactly what it was. ...match-any-error-failed-to-push-some-refs-to-u/64601893#64601893 ... So, if I upgrade git to a newer version, I wouldn't have these issues? I see that I have git version 2.24.3 (Apple Git-128) ... Probably your remote has some commits that aren't on your local git. Try git pull origin master or git push --force origin master, ... More on reddit.com
🌐 r/git
12
1
October 30, 2020
Git - failed to push some refs to ? How come I cannot push to Github ?
Hello, everybody. So I am using Git to push my Java OpenGL project to Github. So when I push my project I get this error ! [rejected] main -> main… More on reddit.com
🌐 r/git
4
0
January 30, 2022
People also ask

What does "Failed to Push Some Refs to" mean in Git?
The "Failed to Push Some Refs to" error occurs when Git cannot push your local commits to the remote repository because your local branch is behind the remote branch or there are conflicts that need to be resolved.
🌐
testkube.io
testkube.io › blog › how-to-fix-failed-to-push-some-refs-to-git-error
Fix "Failed to Push Some Refs" Git Error in 3 Steps
How do I fix Git push rejected errors?
To fix Git push rejected errors, first run `git pull origin` to fetch and merge remote changes, then try pushing again. If conflicts occur, resolve them manually before pushing.
🌐
testkube.io
testkube.io › blog › how-to-fix-failed-to-push-some-refs-to-git-error
Fix "Failed to Push Some Refs" Git Error in 3 Steps
🌐
OneUptime
oneuptime.com › home › blog › how to fix 'failed to push some refs' errors
How to Fix 'Failed to Push Some Refs' Errors
January 24, 2026 - # Common hook rejection messages ... # remote: error: Please use format: PROJ-123: description · Solution: Fix what the hook is complaining about....
🌐
Testkube
testkube.io › blog › how-to-fix-failed-to-push-some-refs-to-git-error
Fix "Failed to Push Some Refs" Git Error in 3 Steps
January 12, 2026 - ... Git displays "failed to push some refs" when your local repository is out of sync with the remote repository, typically because someone else has pushed changes to the same branch since your last pull.
🌐
Kinsta®
kinsta.com › home › resource center › blog › git › how to fix the “error: failed to push some refs to” in git
How To Fix the “Error: Failed to Push Some Refs To” in Git
May 19, 2026 - Git recognizes this inconsistency and will refuse a push to avoid losing any changes. Insufficient permissions. The “error: failed to push some refs to” message could appear if you don’t have sufficient permissions to push changes to remote.
🌐
Host4Geeks
host4geeks.com › host4geeks llc › guides › how to fix the “error: failed to push some refs to” in git : a step-by-step guide
How To Fix the “Error: Failed to Push Some Refs To” in Git : A Step-by-Step Guide
January 21, 2024 - Getting help from someone with ... repository issues! The “Failed to push some refs” Git error occurs when your local and remote histories fall out of sync....
Find elsewhere
🌐
YouTube
youtube.com › watch
How to Fix Git Error: Failed to Push Some Refs to | Github/Gitlab (2026) - YouTube
If you are running into the “failed to push some refs to” error in Git, don’t worry this is one of the most common Git errors developers face when working wi...
Published   September 16, 2025
🌐
Dragganaitool
dragganaitool.com › how-to-fix-the-error-failed-to-push-some-refs-to-in-git
How To Fix the “Error: Failed to Push Some Refs To” in Git - DragGAN AI Tool
October 23, 2025 - Non-existent Remote References: You’re trying to push refs (branches, tags) that no longer exist or weren’t created locally. Permissions Issues: Your Git credentials don’t allow you to push to the specified repository.
🌐
DopeThemes
dopethemes.com › home › git push error solved: how to fix ‘failed to push some refs’ in simple steps
Git Push Error Solved: How to Fix 'Failed to Push Some Refs' in Simple Steps - DopeThemes
September 10, 2024 - Learn how to resolve the Failed to Push Some Refs error in Git, from fixing merge conflicts to safely using force push and rebase in your workflow.
🌐
JSDev
jsdev.space › how-to › git › how to fix the git error 'failed to push some refs to'
How to Fix the Git Error 'failed to push some refs to'
April 17, 2025 - Could happen due to interrupted pushes or network errors. ... You rebased or amended commits, which rewrote history. Your local refs now conflict with remote history. ... This is safer than --force because it ensures no one else pushed since ...
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-fix-git-error-failed-to-push-some-refs-to-remote
How to Fix Git Error: 'failed to push some refs to remote'? - GeeksforGeeks
July 23, 2025 - error: failed to push some refs to 'https://github.com/example/repo' 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 ...
🌐
Sling Academy
slingacademy.com › article › git-push-error-failed-to-push-some-refs
Solving Git Push Error: ‘failed to push some refs’ (3 ways) - Sling Academy
> git push origin master Total 0 (delta 0), reused 0 (delta 0) To https://github.com/username/repo.git b3452e3..f4b2h3j master -> master · Notes: This solution is ideal for simple cases where your local repository is just out-of-date. However, it can cause merge conflicts that you will need to resolve manually. A force push can override the current state of the remote repository with your local state.
🌐
GitHub
github.com › git-lfs › git-lfs › issues › 4140
Can't force push a ref to a remote if local repo doesn't have the commit referred to by the current remote ref · Issue #4140 · git-lfs/git-lfs
May 20, 2020 - Workaround This problem could be ... collect whenever. In any case, the solution I've used is to pull the ref in question from the remote, then run the push again....
Author   git-lfs
🌐
Javaprogramto
javaprogramto.com › 2021 › 11 › error-failed-to-push-some-refs-to.html
[Fixed] Git error: failed to push some refs to in 5 ways JavaProgramTo.com
November 30, 2021 - To solve this error, you need to check what is the default branch on your github.com. Once you find the right branch then you need to switch to the correct branch using git push command.
🌐
freeCodeCamp
freecodecamp.org › news › error-failed-to-push-some-refs-to-how-to-fix-in-git
Error: failed to push some refs to – How to Fix in Git
July 28, 2022 - We can fix the error: failed to push some refs to [remote repo] error in Git using the git pull origin [branch] or git pull --rebase origin [branch] commands.
🌐
PhoenixNAP
phoenixnap.com › home › kb › devops and development › git: "failed to push some refs to" error
Git: "failed to push some refs to" Error
February 5, 2026 - The Git "failed to push some refs to" error appears when a push is rejected by the remote repository. This usually happens because the remote branch contains commits that your local branch does not have.
🌐
GitHub
github.com › git-lfs › git-lfs › discussions › 5835
error: failed to push some refs · git-lfs/git-lfs · Discussion #5835
I've recently written up some detailed responses to similar questions in #5752 (comment) and #5817 (comment); you might take a look at those for further advice. In brief, you'll likely want to run the following and then you'll need to git push --force to overwrite your remote's Git history with the new one.
Author   git-lfs
🌐
Reddit
reddit.com › r/git › github: failed to push some refs to ...
r/git on Reddit: Github: Failed to push some refs to ...
October 30, 2020 - I see that I have git version 2.24.3 (Apple Git-128) ... Probably your remote has some commits that aren't on your local git. Try git pull origin master or git push --force origin master, based on what solution is the best for your case.
🌐
The Code City
thecodecity.com › home › git › how to fix git error: failed to push some refs to | github/gitlab (2025)
How to Fix Git Error: Failed to Push Some Refs to | Github/Gitlab (2025) - The Code City
December 1, 2025 - The “Failed to push some refs” error can be frustrating, but it’s a common problem that can be solved with a little bit of Git knowledge. By understanding the underlying causes and following the solutions outlined in this blog post, you can conquer this Git gremlin and push your code with confidence.