【问题标题】:git pull --rebase with auto merge strategy not working带有自动合并策略的 git pull --rebase 不起作用
【发布时间】:2020-06-27 07:56:27
【问题描述】:

我正在尝试使用自动合并策略拉 rebase,

m-hissain-sk01:sc hissain$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 47 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

error: could not apply b5f4d22... Refactored existing source
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply b5f4d22... Refactored existing source

m-hissain-sk01:sc hissain$ git status
interactive rebase in progress; onto 2d4593d
Last command done (1 command done):
   pick b5f4d22 Refactored existing source
Next commands to do (2 remaining commands):
   pick 4298398 Implemented clean swift version
...

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add/rm <file>..." as appropriate to mark resolution)

    added by us:     MyProj.xcodeproj/project.xcworkspace/contents.xcworkspacedata
    added by us:     MyProj.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
    added by us:     MyProj/Configs/Assets.xcassets/AppIcon.appiconset/Contents.json
        ...

我们的版本将自动解决预期的冲突。但是运行命令后,我仍然看到等待手动解析的未隐藏代码。

为什么不起作用?

【问题讨论】:

  • 这里有几个可能的问题。您应该包含此类命令的实际输出,以及您所期望的(最好是剪切和粘贴的文本,而不是屏幕截图)。
  • 好的,我会尽快更新
  • @torek 为了方便起见,我已经更新了命令和输出。您能帮忙找出问题所在吗?
  • 有人将问题标记为This question does not appear to be about programming。为什么这篇文章似乎与编程无关?

标签: git merge rebase conflict git-pull


【解决方案1】:

您的输出中缺少变基的开头,但我强烈怀疑有以下形式的消息:

CONFLICT (add/add): ...

或:

CONFLICT (rename/delete): ...

在各种其他消息中。虽然您指定了-X ours(至少根据原始问题文本):

git pull --rebase -X ours

-X ours 仅自动解决一些 冲突,而不是所有 冲突。特别是,它不能解决我所说的高级冲突,例如添加/添加或重命名/删除冲突。

此时您必须做的是完成合并操作并使用git rebase --continue 继续变基,或者使用git rebase --abort 中止整个变基操作。请记住,git pull 只是为您运行 两个 Git 命令:

  1. git fetch,然后
  2. (如果成功),git mergegit rebase,参数由步骤 1 中获取的内容确定。

您在步骤 2 中调用的 git rebase 不完整。 (我寻找了一些关于如何解决此类合并的 SO 答案——我知道它们存在——但还没有找到任何好的链接。)编辑:这是添加/添加的答案:Resolving a 'both added' merge conflict in git?

【讨论】:

  • 你是对的,有添加/删除操作。感谢您的澄清。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-25
  • 2021-11-17
  • 2015-10-11
  • 2018-09-08
  • 2017-12-07
  • 1970-01-01
  • 2016-10-27
相关资源
最近更新 更多