Git 1.8:它推送错误:dst ref refs/heads/master 从多个 src 接收
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13373528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git 1.8: it push error: dst ref refs/heads/master receives from more than one src
提问by firedev
Another issue with git 1.8:
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.
建议?它在升级到 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:
仍然没有工作,但origin master
至少工作了:
$ 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
?
好的,那种修复它但问题的原因是什么?为什么 origin/master 突然损坏了?我做了git push origin :refs/heads/refs/heads/master
什么?
.git/config
:
.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.
最后,现在我git push origin master
每次都必须这样做。而最可气的是,一些回购一起工作git push
,但他们中的大多数我得到了补充origin master
,但我不明白为什么,也不能说只有我一个人有这个问题。
回答by jcw
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
回答by Brian Campbell
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
.
看起来您refs
在refs/remotes/origin
. 请注意refs/remotes/origin
,您有一个额外的refs
目录?我不知道这是如何到达那里的,但这可能是导致您出现问题的原因。由于 Git 处理 refs 缩写的方式(允许您删除前缀,只使用像 一样的后缀origin/master
),它可能会因同时使用refs/remotes/origin/master
和 而感到困惑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.
我不知道它是如何进入这种状态的;可能是 Git 工具中的错误,也可能是您在某个时候输入的拼写错误。您通过删除跟踪此重复分支的远程分支解决了一半的问题。我敢打赌git push
,如果您删除refs/remotes/origin/refs
目录,您可以解决问题的另一半,并且可以再次解决。
回答by VonC
Following what is explained in this git old patch(2007!)
遵循这个 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 tellreceive-pack
that it should delete the ref with this commit name.delete_ref()
would be subsequently be called, and check thatresolve_ref()
(which does notcheck for validity of the object) returns the same commit name. Which would fail.
一些 refs 变得陈旧,例如当 forkee 重新定位并丢失了 fork 所需的一些对象时。
处理这些引用的快速而肮脏的方法是删除它们并再次推送它们。但是,
git-push
首先将首先获取 ref 的当前提交名称,由于 ref 未指向有效对象,因此将接收空 sha1,然后告诉receive-pack
它应该删除具有此提交名称的 ref。delete_ref()
随后将被调用,并检查resolve_ref()
(不检查对象的有效性)返回相同的提交名称。哪个会失败。
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.
refs/heads/refs/heads/master
看起来像一个不正确命名为“refs/heads/master”的分支(使用命名空间来定义层次分支名称),并且指向什么。
删除它是正确的举动。
回答by Dushmantha
In my case I had a tag with same name as the branch name. rename branch name and works.
就我而言,我有一个与分支名称同名的标签。重命名分支名称和作品。
回答by ShSehati
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:
返回 > 错误:dst ref refs/heads/353-applyPermissions 从多个 src 接收。但这个有效:
git push origin 353-applyPermissions:353-applyPermissions