更新被拒绝,因为远程包含您本地没有的工作 [英] Updates were rejected because the remote contains work that you do not have locally

查看:30
本文介绍了更新被拒绝,因为远程包含您本地没有的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与几个开发人员组成一个团队,在 BitBucket 上使用 git.我们都在开发一个 dev 分支,在发布之前不会推送到 master.

I'm working on a team with a few developers using git on BitBucket. We are all working on a dev branch, not pushing to master until a release.

其中一位开发人员提交了错误的代码,不小心覆盖了我自己的代码,现在我正在尝试将正确的代码推送回 repo.我已经阅读这个错误几天了,我不能再推送到 repo,因为我收到以下错误:

One of the developers committed incorrect code that overwrote my own by accident, and now I am trying to push the correct code back to the repo. I have been reading about this error for a few days now, I can't push to the repo anymore because I am getting the following error:

 ! [rejected]        master -> dev (fetch first)
error: failed to push some refs to 'https://myusername@bitbucket.org/repo_user/repo_name.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.

我按照说明操作并pull,但随后我收到了合并冲突.输入合并冲突的消息后,我的本地代码现在是其他开发人员意外上传的错误代码(正如 pull 预期的那样).所以我用我提交前复制的备份替换了不正确的代码,当我再次尝试推送时,我得到了同样的错误.

I follow the instructions and pull, but then I receive a merge conflict. After entering a message for the merge conflict, my local code is now the incorrect code that the other developer uploaded by accident (as expected from the pull). So I replace the incorrect code with the backup I copied before committing, and when I try to push again, I get the same error.

真的很令人沮丧,我真的很想帮助我的团队并做出贡献,但我不能因为这个错误.有谁知道如何解决这个问题?我非常感谢任何帮助.

It is really frustrating, I really want to help out my team and contribute, but I can't because of this error. Does anyone know how to solve this issue? I would very much appreciate any help.

如果对任何人有帮助,这些是我为了提交而运行的命令:

These are the commands I run in order to commit if it helps anyone out:

git pull remotename master:dev
git add --all
git commit -m "some message"
git pull remotename master:dev
git push remotename master:dev

我本以为如果我保持这个顺序,我就不会收到合并冲突.我想我错了.再次感谢

I would have thought that if I kept this order, I would not receive merge conflicts. I guess I was wrong. Thanks again

更新:我应该补充一点,我已经在 Google 和 StackOverflow 上寻找了几个小时,并遵循了不同的说明,但我仍然无法pushdev 分支.

Update: I should add that I have looked for a few hours on Google and StackOverflow, and followed different instructions, but I still can't push to the dev branch.

推荐答案

git pull master:dev 将获取 remote/master 分支并将其合并到您的 local/dev 分支中.

git pull <remote> master:dev will fetch the remote/master branch and merge it into your local/dev branch.

git pull <远程>dev 将获取 remote/dev 分支,并将其合并到您当前的分支中.

git pull <remote> dev will fetch the remote/dev branch, and merge it into your current branch.

我想你说冲突提交是在 remote/dev 上,所以那是你可能打算获取和合并的分支.

I think you said the conflicting commit is on remote/dev, so that is the branch you probably intended to fetch and merge.

在那种情况下,您实际上并没有将冲突合并到您的本地分支中,这有点奇怪,因为您说您在工作副本中看到了不正确的代码.您可能想检查 remote/master 中发生了什么.

In that case, you weren't actually merging the conflict into your local branch, which is sort of weird since you said you saw the incorrect code in your working copy. You might want to check what is going on in remote/master.

这篇关于更新被拒绝,因为远程包含您本地没有的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆