Merging two remote repositories in Git
Question
I want to merge two remote repositories in Git.
One is mainstream repository, which I do not have write permission. I want to track its master branch.
The other is maintained by us, I have full rights on it.
I want to track the mainstream code. At the same time, our modification would be recorded in my remote repository.
How do I do this?
Solution
I would recommend:
- cloning
yourRemoteRepo
(that way, you can easily pull/push from that repo) adding
mainstreamRepo
as a remote and fetch its branch, then track the one which interest yougit clone git://yourRemoteRepo git remote add mainStreamRepo http://mainStreamRepo git fetch mainStreamRepo git checkout -b mainStreamMaster mainStreamRepo/master git checkout master
From there, you can
- merge
mainStreamMaster
to yourmaster
, - or rebase your
master
on top ofmainStreamMaster
(in order to integrate the full history ofmainStreamMaster
into yourmaster
branch) - then make some evolutions to
master
(or to a topic-specific branch) that you can push toyourRemoteRepo
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow