Git: failed to push some refs although I have done git pull

前端 未结 7 1452
清酒与你
清酒与你 2021-02-07 01:19

I started to get \'failed to push some refs\' error when I changed some files and tried to do push. Most instructions tell to do git pull first. I have done it and git says ever

7条回答
  •  逝去的感伤
    2021-02-07 02:00

    Also, the error happens when you put the wrong branch name into your push command.

    For example, say you're on a branch called iss8, but you tell git to push to iss3 (like I just did), you'll get the same error.

    $ git push origin iss3
    error: src refspec iss3 does not match any.
    error: failed to push some refs to 'git@myhost.com:myuser/myproject.git'
    

    Hmm, check status:

    $ git status 
    On branch iss8
    nothing to commit, working directory clean
    

    Oh, look, I'm on a different branch. Thanks git for not letting me do something really dumb.

    $ git push origin iss8
    Counting objects: 15, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (9/9), done.
    Writing objects: 100% (9/9), 2.62 KiB | 0 bytes/s, done.
    Total 9 (delta 3), reused 0 (delta 0)
    To git@myhost.com:myuser/myproject.git
     * [new branch]      iss8 -> iss8
    

提交回复
热议问题