git 更新被拒绝,因为遥控器包含您所做的工作

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

Updates were rejected because the remote contains work that you do

gitbitbucket

提问by Leonardo Lima

I'm trying to move a local repository to bitbucket, I'm following this tutorialbut when I do

我正在尝试将本地存储库移动到 bitbucket,我正在关注本教程,但是当我这样做时

git push --all bitbucket 

I got the following meessage error:

我收到以下消息错误:

To https://bitbucket.org/growtec/offshore.git
 ! [rejected]        Leonardo -> Leonardo (fetch first)
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://[email protected]/growtec/offshore.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I'm on master branch and I already did a git pullbut the output was the Everything up-to-date.

我在 master 分支上,我已经做了一个,git pull但输出是最新的。

I saw this questionbut it didn't work for me

我看到了这个问题,但它对我不起作用

回答by Tim Biegeleisen

You did a git pullon the masterbranch, but if you look closely at what your git push --all bitbucketcommand is doing, it's also trying to push the Leonardobranch, which you never pulled. You can try pulling this branch as well, and then push all again:

git pullmaster分支上做了一个,但是如果你仔细观察你的git push --all bitbucket命令正在做什么,它也在试图推动Leonardo你从未拉过的分支。你也可以尝试拉这个分支,然后再次推送所有:

git checkout Leonardo
git pull origin Leonardo
git push --all bitbucket

回答by rased

If everything is already up to date. Try git push -f origin master.-f stands for force commit. Hope this helps.

如果一切都已经是最新的。Try git push -f origin master.-f 代表强制提交。希望这可以帮助。

回答by Seda T.

just this code using terminal :

仅此代码使用终端:

git push -f origin master

git push -f 源主

回答by Pascal Fares

You need to pull (or fetch and merge) the 2 branches master and Leonardo solve all the conflicts commit then push again

您需要拉(或获取并合并)2 个分支 master 和 Leonardo 解决所有冲突提交然后再次推送

回答by phd

git pull origin master
git fetch origin Leonardo:Leonardo
git push --all bitbucket