Git error: src refspec master does not match any

This question already has an answer here:

  • src refspec master does not match any when pushing commits in git 54 answers

  • You've created a new repository and added some files to the index, but you haven't created your first commit yet. After you've done:

     git add a_text_file.txt 
    

    ... do:

     git commit -m "Initial commit."
    

    ... and those errors should go away.


    The quick possible answer: When you first successfully clone an empty git repository, the origin has no master branch. So the first time you have a commit to push you must do:

    git push origin master
    

    Which will create this new master branch for you. Little things like this are very confusing with git.

    If this didn't fix your issue then it's probably a gitolite-related issue:

    Your conf file looks strange. There should have been an example conf file that came with your gitolite. Mine looks like this:

    repo    phonegap                                                                                                                                                                           
        RW+     =   myusername otherusername                                                                                                                                               
    
    repo    gitolite-admin                                                                                                                                                                         
        RW+     =   myusername                                                                                                                                                               
    

    Please make sure you're setting your conf file correctly.

    Gitolite actually replaces the gitolite user's account with a modified shell that doesn't accept interactive terminal sessions. You can see if gitolite is working by trying to ssh into your box using the gitolite user account. If it knows who you are it will say something like "Hi XYZ, you have access to the following repositories: X, Y, Z" and then close the connection. If it doesn't know you, it will just close the connection.

    Lastly, after your first git push failed on your local machine you should never resort to creating the repo manually on the server. We need to know why your git push failed initially. You can cause yourself and gitolite more confusion when you don't use gitolite exclusively once you've set it up.

    链接地址: http://www.djcxy.com/p/48954.html

    上一篇: 为什么我不能推到这个裸仓库?

    下一篇: Git错误:src refspec master与任何不匹配