Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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 '[email protected]:xxx.git'

Suggestions? It was working before upgrading to 1.8.

$ git remote -v
origin  [email protected]:xxx.git (fetch)
origin  [email protected]:xxx.git (push)

After googling around I tried this first:

$ git push origin :refs/heads/refs/heads/master
remote: warning: Allowing deletion of corrupt ref.
To [email protected]:xxx.git
 - [deleted]         refs/heads/master

No idea what is that and why it was corrupt.

$ git pull
Already up-to-date.

$ git push
error: dst ref refs/heads/master receives from more than one src.
error: failed to push some refs to '[email protected]:xxx.git'

Still not working, but origin master did work at least:

$ git push origin master
Counting objects: 42, done.
To [email protected]:xxx.git
3e3fc87..6e11d2a  master -> master

Okay, that kind of fixed it but what was the cause of the issue to begin with? Why origin/master suddenly got corrupted? What did I do with git push origin :refs/heads/refs/heads/master ?

.git/config:

[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:xx.git
push = HEAD
[branch "master"]
remote = origin
merge = refs/heads/master

ls .git/refs/remotes/origin:

HEAD    master  refs

In the end, now I have to do git push origin master every time. And the most annoying is that some repos work with git push, but on the most of them I got to add origin master but I don't understand why, and it can't be that I am alone having this problem.

like image 762
firedev Avatar asked Nov 14 '12 05:11

firedev


3 Answers

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
like image 98
jcw Avatar answered Nov 12 '22 23:11

jcw


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.

like image 30
Brian Campbell Avatar answered Nov 12 '22 22:11

Brian Campbell


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
like image 4
ShSehati Avatar answered Nov 12 '22 23:11

ShSehati