如何在两个本地存储库之间合并 [英] How to merge between two local repositories

查看:74
本文介绍了如何在两个本地存储库之间合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个本地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

这篇关于如何在两个本地存储库之间合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆