【发布时间】:2014-02-17 01:33:21
【问题描述】:
我有两个本地 git 存储库(一个是 master repo 的克隆,另一个是 master 的 fork 的克隆)。有没有办法将一个分支与另一个分支合并?
注意 - 我不能只添加 master 作为 upstream ,因为我们目前有一些问题 - git fetch fails due to pack-object failure。
【问题讨论】:
我有两个本地 git 存储库(一个是 master repo 的克隆,另一个是 master 的 fork 的克隆)。有没有办法将一个分支与另一个分支合并?
注意 - 我不能只添加 master 作为 upstream ,因为我们目前有一些问题 - git fetch fails due to pack-object failure。
【问题讨论】:
您可以添加另一个远程存储库,例如“本地”。
试试下面的方法(我刚才跑成功了):
(假设您的本地存储库是同一文件夹中的 MyGitRepo.git 和 AnotherRepo.git)
在 MyGitRepo.git 文件夹中:
$: git remote add local ../AnotherRepo
$: git fetch local
$: git merge local/master
如果master是你要合并的分支。
git fetch local之后,你可能会看到以下内容:
$ git fetch local
From ../AnotherRepo
* [new branch] master -> local/master
这意味着成功创建了另一个跟踪分支来跟踪(其他)本地存储库。
参考: 阅读this link 了解多个远程存储库
【讨论】:
fatal: refusing to merge unrelated histories -> 添加--allow-unrelated-histories 了解更多信息检查:stackoverflow.com/questions/37937984/…