如何在两个本地存储库之间合并
我有两个本地git存储库(一个是master repo的克隆,另一个是master的fork的克隆).有没有一种方法可以将一个分支与另一个分支合并?
I have two local git repositories (one is a clone of master repo, other is a clone of fork of master). Is there a way to merge a branch of one with the same branch from other?
注意-我不能只将master添加为上游,因为当前存在一些问题-
Note - I can't just add the master as upstream , because we have some issues that way currently - git fetch fails due to pack-object failure .
您可以添加另一个远程存储库,例如本地".
You could add another remote repository such as 'local'.
尝试以下方式(我刚刚成功运行):
Try the following way (which I just ran successfully):
(假设您的本地存储库是同一文件夹中的MyGitRepo.git和AnotherRepo.git)
(Suppose your local repositories are MyGitRepo.git and AnotherRepo.git in the same folder)
在MyGitRepo.git文件夹中:
in MyGitRepo.git folder:
$: git remote add local ../AnotherRepo
$: git fetch local
$: git merge local/master
如果master是您要合并的分支.
If master is the branch you want to merge.
在git fetch local
之后,您可能会看到以下内容:
After git fetch local
, you will probably see the following:
$ git fetch local
From ../AnotherRepo
* [new branch] master -> local/master
这意味着成功创建了另一个跟踪分支来跟踪(其他)本地存储库.
which means that another tracking branch is successfully made to track the (other) local repository.
参考: 阅读关于多个远程存储库的此链接
Ref: read this link about multiple remote repositories