问题
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