Git 1.8: it push error: dst ref refs/heads/master receives from more than one src

后端 未结 5 1659
野趣味
野趣味 2021-02-18 17:43

Another issue with git 1.8:

$ git push
error: dst ref refs/heads/master receives from more than one src.
error: failed to push some refs to \'gitosis@xxx.xx:xxx.         


        
相关标签:
5条回答
  • 2021-02-18 17:56

    Another way to get this error is if you accidentally type in the name of the branch you are trying to push twice, i.e.:

    git push master otherBranch master moreBranches
    

    Yields this error. Fix is obvious once you're aware you've done it:

    git push master otherBranch moreBranches
    
    0 讨论(0)
  • 2021-02-18 18:06

    Following what is explained in this git old patch (2007!)

    Some refs go stale, e.g. when the forkee rebased and lost some objects needed by the fork.
    The quick & dirty way to deal with those refs is to delete them and push them again.

    However, git-push first would first fetch the current commit name for the ref, would receive a null sha1 since the ref does not point to a valid object, then tell receive-pack that it should delete the ref with this commit name.
    delete_ref() would be subsequently be called, and check that resolve_ref() (which does not check for validity of the object) returns the same commit name. Which would fail.

    refs/heads/refs/heads/master looks like a branch improperly named "refs/heads/master" (using namespaces for defining hierachical branch name), and points to nothing.
    Deleting it was the right move.

    0 讨论(0)
  • 2021-02-18 18:08

    It looks like you have an extra copy of your refs tree within refs/remotes/origin. Notice how within refs/remotes/origin, you have an extra refs directory? I don't know how this got there, but it's probably what is causing your problems. Due to the way Git handles abbreviations of refs (allowing you to drop the prefix, using only the suffix like origin/master), it is probably getting confused by having both refs/remotes/origin/master and refs/remotes/refs/remotes/origin/master.

    I don't know how it got into this state; possibly a bug in a Git tool, possibly a typo that you made at some point. You fixed half of the problem by deleting the remote branch that was tracking this duplicate branch. I would be willing to bet you can fix the other half of the problem, and be able to do git push again, if you delete the refs/remotes/origin/refs directory.

    0 讨论(0)
  • 2021-02-18 18:12

    In my case I had a tag with same name as the branch name. rename branch name and works.

    0 讨论(0)
  • 2021-02-18 18:16

    in my case I had a space in branch name:

    git push origin 353-applyPermissions :353-applyPermissions
    

    returns > error: dst ref refs/heads/353-applyPermissions receives from more than one src. but this one works:

    git push origin 353-applyPermissions:353-applyPermissions
    
    0 讨论(0)
提交回复
热议问题