我正在尝试使用git将多个提交从一个项目移至第二个,类似的提交。
所以我创建了一个补丁,其中包含5个提交:
git format-patch 4af51 --stdout > changes.patch
然后将修补程序移动到第二个项目的文件夹,并要应用该修补程序:
git am changes.patch
...但是它给我错误:
Applying: Fixed products ordering in order summary.
error: patch failed: index.php:17
error: index.php: patch does not apply
Patch failed at 0001 Fixed products ordering in order summary.
The copy of the patch that failed is found in:
c:/.../project2/.git/rebase-apply/patch
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".
所以我打开了index.php,但是那里什么都没有改变。我假设有一些>>>>>>>标记等,例如在解决合并冲突时,但文件中未标记任何冲突。git status还给了我一个空的已更改文件列表(仅changes.patch存在)。所以我运行git am --continue,但是出现另一个错误:
Applying: Fixed products ordering in order summary.
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.
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".
我正在使用Windows 7和最新的git版本“ 1.9.4.msysgit.1”
PS经过数小时的谷歌搜索,我发现了很少的解决方案,但对我没有任何帮助:
git am -3 changes.patch
给出奇怪的“ sha1信息”错误:
Applying: Fixed products ordering in order summary.
fatal: sha1 information is lacking or useless (index.php).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 Fixed products ordering in order summary.
The copy of the patch that failed is found in:
c:/.../project2/.git/rebase-apply/patch
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".
git am changes.patch --ignore-whitespace --no-scissors --ignore-space-change
给出上面的第一个错误:“错误:修补程序失败:index.php:17”,但未index.php添加任何冲突标记。