gpt4 book ai didi

git - 如何将 git am 的 "patch does not apply"解决为 merge 冲突?

转载 作者:行者123 更新时间:2023-12-05 03:56:20 28 4
gpt4 key购买 nike

我希望将一些提交从一个存储库移动到另一个存储库,我想保留原始提交、日期和提交消息等所有内容,而不是将整个内容压缩在一起。 git format-patch master明白了,每次提交都制作一个 .patch 文件,但我在应用它们时遇到了一些麻烦(我卡在了第一次提交上)。

git apply <patch file name>干净地应用更改,没有冲突或任何东西,但当然它不会创建我想要的提交。

git am --committer-date-is-author-date -3 < <patch file name> ,另一方面,没有明确的解决方法失败:

Applying: <original commit message>
error: patch failed: war/WEB-INF/web.xml:162
error: war/WEB-INF/web.xml: patch does not apply
<more files listed, all of them ones that I've modified in the commit; newly created files are not listed>
error: Did you hand edit your patch?
It does not apply to blobs recorded in its index.
hint: Use 'git am --show-current-patch' to see the failed patch
Using index info to reconstruct a base tree...
M war/WEB-INF/web.xml
Patch failed at 0001 <commit message>
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

运行后,我的工作副本或暂存副本没有任何变化。我希望得到带有 merge 冲突样式标记( <<<<<<<<>>>>>>>> )的更改文件,因为我使用了 -3旗帜,但我什至没有。

有没有办法运行git am得到我想要的东西,还是应该使用 git apply并做出新的 promise ?

最佳答案

你可以试试--reject .它应用补丁的适用部分,并将被拒绝的大块留在相应的 *.rej 文件中。当 -3 不能正常工作时,它会有所帮助。

关于git - 如何将 git am 的 "patch does not apply"解决为 merge 冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59453367/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com