如何 git cherry-pick 使用二进制文件提交

How to git cherry-pick a commit with binary files

我正在尝试从主要是二进制文件的不同分支中挑选一个提交。看起来它基本上是成功的,除了我收到消息的一个文件:

warning: Cannot merge binary files: XXXX.so (HEAD vs. d8ef550... Add support for 32-bit apk)
error: could not apply d8ef550... Add support for 32-bit apk
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

我可以对该文件执行 'git add',但结果不是我所期望的。我希望它是一个修改,但结果是删除了那个有问题的文件。我尝试挑选的提​​交修改了一些二进制文件并删除了一些。

所以,问题是……挑选二进制文件提交的最佳方法是什么?

您可以使用 git cherry-pick --strategy=recursive -X theirs {Imported_Commit}

(您可能需要先中止当前的 cherry-pick;git cherry-pick --abort