Я пытаюсь переместить несколько коммитов из одного проекта во второй, аналогичный, используя 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"
P.S. После нескольких часов работы в Интернете я нашел несколько решений, но для меня ничего не работает:
git am -3 changes.patch
дает странную ошибку "sha1 information":
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
дает первую ошибку, как указано выше: "error: patch failed: index.php: 17", но никаких пометок конфликта в index.php
не было добавлено.