git github 问题 - 错误:无法推送一些引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17741552/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:48:02  来源:igfitidea点击:

github issue - error: failed to push some refs

gitgit-pushgit-pull

提问by CHarris

I'm trying to push my master branch to my production branch.

我正在尝试将我的主分支推送到我的生产分支。

Normally when I do changes on my Ubuntu computer I push to master by:

通常,当我在我的 Ubuntu 计算机上进行更改时,我会通过以下方式推动掌握:

git add .
git commit -m "message"
git push

And everything works fine. Then I simply do:

一切正常。然后我简单地做:

git push origin master:production

And everything works fine. But now for some reason when I do the 'git push origin master:production' in Terminal I get the message:

一切正常。但是现在由于某种原因,当我在终端中执行 'git push origin master:production' 时,我收到消息:

To [email protected]:Username1/myapp.git
 ! [rejected]        master -> production (non-fast-forward)
error: failed to push some refs to '[email protected]:Username1/myapp.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.
mypc@ubuntu:~/myapp$ 

How can I fix this irritating problem that has mysteriously arisen? I tried 'git pull origin master', as suggested in the message and elsewhere in my research, but all I get in Terminal is 'everything up to date' and the problem reoccurs when I try it again. Thanks.

我该如何解决这个神秘出现的恼人问题?我尝试了“git pull origin master”,正如消息和我研究中的其他地方所建议的那样,但我在终端中得到的只是“一切都是最新的”,当我再次尝试时,问题再次出现。谢谢。

回答by Paul Verest

Somebody has already committed to production branch.

有人已经致力于生产分支。

As @user1281385 said you should

正如@user1281385 所说,你应该

git pull origin master:prooductionor better before review changes on production branch in other way.

git pull origin master:prooduction或者在以其他方式生产分支的更改之前更好。

try git help pullto read more.

尝试git help pull阅读更多。

回答by beyersdorfinger

remote changes are done on the repository. as the error messages says:

远程更改在存储库上完成。正如错误消息所说:

Merge the remote changes (e.g. 'git pull') before pushing again.

pull first, then push.

先拉,后推。

回答by PasQualE

You can try git push origin --force master:productionif you have done a reset between this push and the last one.

您可以尝试git push origin --force master:production是否在此推送和上一次推送之间进行了重置。