【发布时间】:2022-01-08 15:29:36
【问题描述】:
我正在与几个在 BitBucket 上使用 git 的开发人员组成一个团队。我们都在开发dev 分支,在发布之前不会推送到master。
其中一位开发人员提交了错误的代码,不小心覆盖了我自己的代码,现在我正试图将正确的代码推回 repo。我已经阅读这个错误几天了,我无法再推送到回购,因为我收到以下错误:
! [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 所预期的那样)。所以我用提交前复制的备份替换了不正确的代码,当我再次尝试推送时,我得到了同样的错误。
这真的很令人沮丧,我真的很想帮助我的团队并做出贡献,但我不能因为这个错误。有谁知道如何解决这个问题?我将非常感谢任何帮助。
如果它可以帮助任何人,我会运行这些命令:
git pull remotename master:dev
git add --all
git commit -m "some message"
git pull remotename master:dev
git push remotename master:dev
我原以为如果我保持这个顺序,我就不会收到合并冲突。我想我错了。再次感谢
更新:
我应该补充一点,我在 Google 和 StackOverflow 上找了几个小时,并按照不同的说明进行操作,但我仍然无法将 push 转到 dev 分支。
【问题讨论】:
-
当您发出
git push时,当您当前在另一个 repo 的目录中时,会显示相同的错误消息 .... git 消息应该更新以反映这一点,特别是因为它的语气听起来很权威否则说服
标签: git version-control merge commit bitbucket