我想将一些提交从一个仓库移动到另一个仓库,并且我希望保留原始的提交、日期和提交消息,而不是将整个内容压缩在一起。git format-patch master可以做到这点,为每个提交制作一个.patch文件,但我在应用它们时遇到了一些问题(我卡在了第一个提交上)。git apply 可以干净地应用更改,没有冲突或其他问题,但当然它不会创建我想要的提交。另一方面,git am --committer-date-is-author-date -3 < 失败了,没有明确的解决方法。
运行完这个命令后,我的工作副本或暂存区没有任何更改。我本来期望会得到带有合并冲突标记的更改文件(如
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".
运行完这个命令后,我的工作副本或暂存区没有任何更改。我本来期望会得到带有合并冲突标记的更改文件(如
<<<<<<<<
和>>>>>>>>
),因为我使用了-3
选项,但实际上我连那些都没有。是否有一种方法可以运行git am
以获得我想要的结果,或者我应该使用git apply
并创建新的提交?
--reject
。冲突的块将保存在.rej
文件中。 - ElpieKay