How to merge between two local repositories

怎甘沉沦 提交于 2019-12-21 09:14:16

问题


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?

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 .


回答1:


You could add another remote repository such as 'local'.

Try the following way (which I just ran successfully):

(Suppose your local repositories are MyGitRepo.git and AnotherRepo.git in the same folder)

in MyGitRepo.git folder:

$: git remote add local ../AnotherRepo
$: git fetch local
$: git merge local/master

If master is the branch you want to merge.

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



来源:https://stackoverflow.com/questions/21360077/how-to-merge-between-two-local-repositories

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!