The Error: SRC Refspec Master Does Not Match Any happens when you forget to add the files you changed to a commit and try to push those changes to a remote repository before you make the first commit in your repository.
You have to add a file to a commit before you can push your changes to a remote Git repository. If you create a new repository and forget to add a file to a commit, you may get the src refspec master does not match any error.
What Does Error SRC Refspec Master Does Not Match Any Mean?
When you try to push from a local repository to a
master repository, you may get this error:
git push origin master
This mistake can happen for a number of reasons. Most of the time, this error happens because the master branch doesn’t exist.
Maybe you cloned a new repository and the main branch is the default, so when you try to push for the master branch, there isn’t one.
git branch -b command, you can see the remote branches that are linked to a local repository:
git branch -b # results # origin/main # origin/feat/authentication # origin/other branches ...
From the above results, you can see that there is no
master repository (
origin/master). So, if you try to push to that repository, you will get the “respec error.”
This result also holds for any other branch that doesn’t exist. Say, for example, I make changes and push them to a remote branch called “
hello” that doesn’t exist:
git add . git commit -m "new changes" git push origin hello
This command will provide you the following error:
error: src refspec hello does not match any
How To Solve Error: SRC Refspec Master Does Not Match Any?
Now that you know the
master branch doesn’t exist, you can move on. To fix this error, either create a local and remote
master branch that you can push the commit to, or push the commit to an existing branch, like
You can create a remote
master branch on a Git-managed website like GitHub, or you can do it directly from your terminal:
git checkout -b master # add commit git push origin master
With these commands, a local
master branch will be made. And by pushing to
origin master, the master branch will also be made remotely.
But if you don’t want to make a
master branch, you can use the default branch instead, which may be called
So, if you try to push to master and get the
error: src refspec master does not match any, the most likely reason is that the master branch does not exist.
In this article, we have discussed why Error: SRC Refspec Master Does Not Match Any Occurs when we executing the command, also we have discussed on how to solve this issue. I hope this simple tutorial will help you, Thank You and God Bless!
By the way if you encounter an error about importing libraries, I have here the list of articles made to solve your problem on how to fix error in libraries.
- ModuleNotFoundError: No Module Named Pycocotools
- ERROR: Error:0308010c:Digital Envelope Routines::Unsupported
- Only Size-1 Arrays Can Be Converted To Python Scalars
- AttributeError: Module TensorFlow Has No Attribute Contrib
- ‘Smote’ Object Has No Attribute ‘fit_sample
- NameError: Name plot_cases_simple Is Not Defined
- AttributeError: HTMLParser Object Has No Attribute Unescape
However, If you have any questions or suggestions about this tutorial about Error: SRC Refspec Master Does Not Match Any, Please feel to comment below.