error: failed to push some refs to 'https://github.com/
Solution 1
I had the same problem but this command resolved it.
Replace:
git push -u origin master
with following command:
git push -u origin main
or
git push -f origin main
Solution 2
Just give a try to the following command:
git push origin master --force
Solution 3
check maybe you are trying to push without commiting. try to commit you changes.
git commit -m "my commit"
or type git branch
to see if you have set the remote url. if nothing shows up, then add the remote origin url git remote add origin https://github.com/username/projectname.git
.
then try git push origin master
Solution 4
This helped me.
git push origin master:main
Which master
is my local branch and main
is my remote branch. I think this happened because Github renamed master to main
Solution 5
it's work on my case
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
add your mail and name of github
Related videos on Youtube
koeradoera
Updated on January 04, 2022Comments
-
koeradoera over 2 years
this is my repository https://github.com/kiotie32/artbit-text.git when I do
$ git push -u origin master remote: Repository not found. fatal: repository 'https://github.com/kiotie32/arbit-text.git/' not found
I am on a Windows 10 machine. I had configured ssh keys to be used with this laptop. I do an ls and I can see
MINGW64 ~/.ssh $ ls kiotie32_rsa kiotie32_rsa.pub known_hosts
I read all the answers given on this thread I changed the password stored in windows credential manager.
I check
git remote -v | head -n1 | awk '{print $2}' | sed 's/.*\///' | sed 's/\.git//'
I get following outputarbit-text
I changed the password stored in windows credentials manager probably an old password was stored.
I do not get any popup asking username password. (an ssh key was configured but not sure if that is working on this Windows 10 environment I have the key stored in .ssh in git bash) Now I do
$ git remote add origin https://github.com/kiotie32/arbit-text.git fatal: remote origin already exists.
then I do
$ git push -u origin master error: src refspec master does not match any error: failed to push some refs to 'https://github.com/kotie32/arbit-text.git'
So I am not able to understand why this error is coming/
I tried the solution here https://stackoverflow.com/a/7572252/13012032 first answer to do
git commit -m "initial master"
and then I got
$ git push origin master remote: Repository not found. fatal: repository 'github.com/kotie32/arbit-text.git' not found
then I tried as in comments
git add -all
and then I did
$ git push origin master remote: Repository not found. fatal: repository 'https://github.com/kotie32/arbit-text.git/' not found
then from another answer https://stackoverflow.com/a/4183856/13012032 I tried
$ git show-ref 79d1730e9aa78f68a11ec4de6a0e8d6b66f17afb refs/heads/master
then I did
$ git push origin HEAD:master remote: Repository not found. fatal: repository 'https://github.com/kotie32/arbit-text.git/' not found
I notice in the last error on above url spelling kotie32 is wrong it should be
kiotie32
checkd the config file inside the .git folder and there I see the following[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = https://github.com/kiotie32/arbit-text.git fetch = +refs/heads/*:refs/remotes/origin/*
so here url is corrrect the spelling is
kiotie32
which is correct.ok I now noticed that 2 directories have formed.
project folder/.git/.git
and config file of<project folder>/.git
has wrong url and the inner one i.e.<project folder>/.git/.git
has correct url.I changed the config file of
<project folder>/.git
and deleted subdirectory.git/.git
the new config file has[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = https://github.com/kiotie32/arbit-text.git fetch = +refs/heads/*:refs/remotes/origin/*
and then I again do
$ git push -u origin master remote: Repository not found. fatal: repository 'https://github.com/kiotie32/arbit-text.git/' not found
then I did
$ git remote set-url origin https://github.com/kiotie32/artbit-text.git
then now I am able to push to master branch.
-
phd about 4 yearsDoes this answer your question? Message 'src refspec master does not match any' when pushing commits in Git
-
phd about 4 years
-
koeradoera about 4 yearsI tried the solution given on your first link's first answer to do
git commit -m "initial master" and then I got
$ git push origin master remote: Repository not found. fatal: repository 'github.com/kotie32/arbit-text.git' not found` then I tried as in commentsgit add -all
and then I did$ git push origin master remote: Repository not found. fatal: repository 'https://github.com/kotie32/arbit-text.git/' not found
-
phd about 4 years
-
Enlico about 4 yearsDoes this answer your question? git error: failed to push some refs to
-
koeradoera about 4 yearsI by now deleted every thing and did every thing again from scratch I don't remember what errors came when I posted the question. Things are working fine on my laptop as of now.
-
hamid Mahmoodi over 2 yearsMaybe there is no
master
branch, testmain
:D
-
-
koeradoera almost 4 yearsNo that was not the problem by the time you answer I posted question on 12 march 2020 you answered 19/5/2020 , I already gave a solution in my question as how I solved. The problem was I had two .git folders one folder was inside another git and also the remote repository link was wrong so I deleted them and again did all things from scratch. Then it worked
-
Gino Mempin almost 3 years
git branch master
does not "change our current branch to master branch" It will try to create a master branch, but you will still be in the same branch. -
4xMafole almost 3 yearsAppreciate so much. This answer did the trick.
-
Zach Saucier almost 3 yearsSince I have multiple git accounts that I use, I did not include the
--global
flag, but this fixed the issue for me. -
Marco Mesen almost 3 yearsIt works for me, but I don't know why, because I had already setup it
-
Eklavya Chandra over 2 yearsbut what about change in branch? I want to push directly to the main branch
-
Eric Aya over 2 yearsThis is the same solution as in this other answer. When answering older questions that already have answers, please make sure you provide either a novel solution or a significantly better explanation than existing answers.
-
Admin over 2 yearsAs it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
-
helvete over 2 yearsThank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you’ve made.
-
nima over 2 yearsWhile this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. You can find more information on how to write good answers in the help center: stackoverflow.com/help/how-to-answer . Good luck 🙂
-
Amitesh mani tiwari over 2 years@EklavyaChandra I will suggest this article stevenmortimer.com/…