Message 'src refspec master does not match any' when pushing commits in Git

前端 未结 30 1749
轮回少年
轮回少年 2020-11-22 02:49

I clone my repository with:

git clone ssh://xxxxx/xx.git 

But after I change some files and add and commit them,

相关标签:
30条回答
  • 2020-11-22 02:52

    This happens when you have added your file, forgot to commit and pushing. So commit the files and then push.

    0 讨论(0)
  • 2020-11-22 02:53

    Maybe you just need to commit. I ran into this when I did:

    mkdir repo && cd repo
    git remote add origin /path/to/origin.git
    git add .
    

    Oops! Never committed!

    git push -u origin master
    error: src refspec master does not match any.
    

    All I had to do was:

    git commit -m "initial commit"
    git push origin master
    

    Success!

    0 讨论(0)
  • 2020-11-22 02:53

    This happens too when you are in a specific branch and try to push another branch that does not exist yet, like:

    $ git branch
    * version-x  # you are in this branch
      version-y
    
    $ git push -u origin master
    error: src refspec master does not match any.
    error: failed to push some refs to 'origin_address'
    
    0 讨论(0)
  • 2020-11-22 02:53

    My issue was that the 'master' branch hadn't been created locally yet.

    A quick

    git checkout -b "master"
    

    created the master branch, at which point, a quick

    git push -u origin master
    

    pushed the work up to the Git repository.

    0 讨论(0)
  • 2020-11-22 02:54
    1. First, git add .
    2. Second, git commit -m "message"
    3. Third, git push origin branch

    Please check for spelling mistakes because that could also give that error.

    0 讨论(0)
  • 2020-11-22 02:55

    You probably forgot the command "git add ." after the "git init" command.

    0 讨论(0)
提交回复
热议问题