1

在 11 月份有大约 133 次提交的项目,我已经克隆了该项目并在 50 次提交之前创建了一个新的 repo,这意味着:

A----B----C----D----E
          Cloned New Repo from C
           \__ C

现在新仓库中大约有 15-20 个提交,但是没有提交被推送到旧仓库,但是在编码许多文件并在内部进行了更改时。

A----B----C----D----E
          Cloned New Repo from C
           \__ C----C1----C2---C3---C4

现在我想将这两个 repo 合并为一个:

A----B----C----D----E----C1----C2---C3---C4

搜索互联网后得到一些命令并尝试与以下合并:

 git --git-dir=../<some directory>/.git|
    format-patch -k -15 --ignore-space-at-eol --stdout <commit SHA>|
    git am -k -3

它给出了第一次提交的confilts并成功解决了它:

 git mergetool
 gm am --continue

显示错误:

Did you hand edit your patch?
It does not apply to blobs recorded in its index.
Cannot fall back to three-way merge.
Patch failed at 0002 XXXXXXX
The copy of the patch that failed is found in:
   /xxxxxx/.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".

如果可能,如何解决这个问题?

还有其他方法可以解决此问题吗?

4

1 回答 1

1

我会避免使用“am”方法——如果你真的有共同的历史,你应该利用 rebase、merge 或cherry。

假设您在 E 有一个名为“master”的分支

将第二个存储库作为远程存储库添加到第一个存储库。假设我将新的遥控器命名为“沙盒”。

获取--全部

现在在 sandbox/C4 创建一个新的本地分支 .. 假设该分支名为“otherwork”。检查该分支并在“master”之上重新设置。如果您在解决任何问题时遇到问题,您可以从“otherwork”分支中一次查看 master 和cherrypick 更改。

于 2015-12-06T01:07:21.637 回答