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?

Was it helpful?

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

  • merge mainStreamMaster to your master,
  • or rebase your master on top of mainStreamMaster (in order to integrate the full history of mainStreamMaster into your master branch)
  • then make some evolutions to master (or to a topic-specific branch) that you can push to yourRemoteRepo.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top