Fix: error: src refspec master does not match any failed to push some refs to Git


At times one may face an error when they try to push a branch to the origin.

git push origin master
Error:
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/---/repository.git

Reason:

One of the most common problems that cause this error is that your project is not a git project, thus you cannot push it to the origin straight ways.


Fix:

You need to follow all the steps to make the current project a git-managed project first.

  1. Initialize the project as a git project.
    git init
  2. Add all files to the staging area.
    git add .
  3. Commit your code to the local repo.
     git commit -m 'initial commit.'
  4. Now you are good to move the project to git origin.
     git push -u origin master
error- src refspec master does not match any git

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap