查找错误来源:git push denied: error: failed to push some refs
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19868366/
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
Find source of mistake: git push rejected: error: failed to push some refs
提问by ledy
In one of the teams, when working with git, again and again we run into "git push rejected: error: failed to push some refs"
在其中一个团队中,当使用 git 时,我们一次又一次地遇到“git push denied: error: failed to push some refs”
To [email protected]:ledy/thakres.git ! [rejected]
b_stable -> b_stable (non-fast-forward) error: failed to push some refs to '[email protected]:ledy/thakres.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
到 [email protected]:ledy/thakres.git ![rejected]
b_stable -> b_stable (non-fast-forward) error: failed to push some refs to '[email protected]:ledy/thakres.git' 为了防止你丢失历史,非快-转发更新被拒绝 在再次推送之前合并远程更改(例如“git pull”)。有关详细信息,请参阅“git push --help”的“关于快进的注意事项”部分。
Of course, we can continue with "-f" as quick'n'dirty - not really a - solution.
当然,我们可以继续使用“-f”作为快速解决方案 - 不是真正的 - 解决方案。
However, we'd like to know where this comes from or what's the reason for this rejection.
但是,我们想知道这是从哪里来的或拒绝的原因是什么。
Can't git give verbose details about the reason why it's rejecting, maybe the file which is causing the conflict?
git 不能详细说明拒绝的原因,也许是导致冲突的文件?
We have a suspect on .gitignore which was causing similar issues on another project.
我们在 .gitignore 上有一个嫌疑人,它在另一个项目中引起了类似的问题。
回答by torek
Git doesn't push individual files one at a time, it pushes complete commit trees, as in, "here is how the entire project looked at one commit, and then it looked like that at another, and now finally it looks like this".
Git 不会一次推送一个文件,而是推送完整的提交树,就像“这是整个项目在一次提交时的样子,然后在另一次提交时看起来像这样,现在最终看起来像这样” .
Drawn as a graph of commits, this is, e.g., the very linear:
绘制为提交图,例如,这是非常线性的:
...--D--E--F--G <-- master
What's being "rejected" is that the "finally" you're supplying is not "forward progress" from the "finally" the remote had before, i.e., you're missing some "forward progress" that someone elseput in. You had:
被“拒绝”的是,您提供的“最终”不是遥控器之前“最终”的“前进进度”,即,您错过了其他人输入的一些“前进进度” 。您有:
...--D <-- master
and then you added commits E
, F
, and G
. But while you were doing that, someone else picked up the series of commits ending in D
and added his or her own commit H
:
然后你加入提交E
,F
和G
。但是当你这样做的时候,其他人拿起了以 结尾的一系列提交D
并添加了他或她自己的提交H
:
...--D--H <-- master
You're proposing to throw away H
and make the commit sequence look like yoursequence: D
is followed by E
-through-G
and that's the end of everything.
您提议丢弃H
并让提交序列看起来像您的序列:D
后跟E
-through- G
,这就是一切的结束。
Git tells you the branch namethat has the progress you're proposing to throw away, in this case, master
. It's up to you to git fetch
the progress and then retain it, perhaps by git merge
creating a merge commit M
:
Git 会告诉您具有您建议丢弃的进度的分支名称,在本例中为master
. git fetch
进度取决于您,然后保留它,也许通过git merge
创建合并提交M
:
H------
/ \
...--D M <-- master
\ /
E--F--G
or perhaps by "rebasing" your series of commits on top of H
:
或者也许通过在以下基础上“重新设定”您的一系列提交H
:
...--D--H-E'-F'-G' <-- master
(where E'
, F'
, and G'
are versions of "what changed in E
, F
, and G
" with just enough changed to make them apply on top of H
instead—quite often that's just commit parentage, occasionally there's a bit more work involved).
(其中E'
,F'
和G'
是版本“什么改变E
,F
以及G
”只有足够的改变,使它们应用之上H
,而不是,往往这只是犯出身,偶尔有涉及更多的工作)。
回答by Guillermo Mansilla
Do a git pull, then try to push, that's what the message is saying.
执行 git pull,然后尝试推送,这就是消息所说的。
回答by rabby
This can be a hard to find issue that I had several times, when disk is not sync or overload, high iowait.
这可能是一个很难发现的问题,我遇到过几次,当磁盘不同步或过载时,iowait 很高。
Is git show-branch --list --all
worrying about ambigious branch names: "warning: refname xyz is ambiguous"?
是否git show-branch --list --all
担心分支名称不明确:“警告:refname xyz 不明确”?
If so, try
如果是这样,请尝试
$ rm -rf .git/refs/heads/origin/xyz
$ git branch --set-upstream lkgr origin/xyz
$ rm -rf .git/refs/heads/origin/xyz
$ git branch --set-upstream lkgr origin/xyz