There are a few reasons Git throws an error: src refspec master does not match any. Let’s figure it out. This is a detailed article and I fully tried to cover all errors that I faced. And step by step I cover the fixing of src refspec master does not match any…
Error type:
git push -u origin master
error: src refspec master does not match any.
error: Please make sure you have the correct access rights and the repository exists.
Step 1: Check credentials using Credential Manager
Sometimes we use one or more github accounts in same OS so let’s check it. Go to windows search and type “Credential Manager”. Open Windows Credentials and check Github account details in Generic Credentials.
Here we can see the username of the Github account. if the username is correct then proceed to the next step. Or if you have any doubt regarding the password then click Edit the and your Github account password and save it. Note: Restart your system (optional)
Step 2 Check Git remote origin
git init
git remote -v
The -v flag
lets us see the URLs to which our repository is pointing:
origin https://github.com/devhassam/ticket-reservation.git (fetch)
origin https://github.com/devhassam/ticket-reservation.git (push)
If no line appears after running git remote -v
then you first need to register git repo. Or if details are shown like in the above image then skip the next step.
git remote add origin /path/to/origin.git
e.g
git remote add origin https://github.com/devhassam/ticket-reservation.git
Pushing the changes to the master or remote branch
Solution
git remote add origin /path/to/origin.git
git add .
git commit -m "First commit"
git push origin master
If the error is still there then just add -u flag
with git push origin master
git remote add origin /path/to/origin.git
git add .
git commit -m "First commit"
git push origin -u master
After adding -u flag a Github Authentication POP-UP would appear. Add Github username and password, or simply login using Token. If you choose Token then the pop-up will show a 6-digit code with github link. Copy the code and open the link where you need to add copied code and hit Authenticate.
Thank you! And I hope this article is helpful.
https://hassam.me
Top comments (0)