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?
If you actually want to merge both repos, this step is unnecessary. $ git rm -rf * $ git commit -m "Delete all the things." Merge master-holder into master. (If you didn't do the delete step above, you have to option of git checkout master-holder; git rebase master instead.)
Merging Branches in a Local Repository To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch.
You can add multiple remotes by using git remote or git config commands or editing the config file. As git can group multiple remotes, you can follow any of the following ways to configure multiple remotes to push simultaneously(no need all). You can set multiple remote URLs to a single remote using git remote.
I would recommend:
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 you
git 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
mainStreamMaster
to your master
, master
on top of mainStreamMaster
(in order to integrate the full history of mainStreamMaster
into your master
branch)master
(or to a topic-specific branch) that you can push to yourRemoteRepo
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With