I have 3 different git repositories:
- An open source project
- My own fork of the project on GitHub, which was forked from 1.
- My local repository, which was cloned from 2.
I work on 3., and can push/pull changes to/from 2.
However, there are now changes in 1. which I would also like to merge into my own fork. I think what I want to do is pull the changes from 1. into a remote tracking branch in 3., do the merge locally, then push out to 2...... is that sensible?
If so, how do I best achieve this in EGit? In particular I'm not sure how I should get Egit to pull in the changes from 1. when it is already configured to push/pull from 2.
Not sure how to do this in egit, but if you want to try command line. First add a remote for repo 1:
git remote add <remote_name> <url_of_open_source_project>
You can now see your remote repos by typing:
git remote -v
Create a new branch which will be used to merge in repo's 1 code:
git checkout -b <branch_name>
Fetch repo 1 and then merge repo 1's branch into your local branch:
git fetch <remote_name>
git merge <remote_name>/<remote's branch_name>
After this, you can push onto your github fork (assuming the remote name is origin):
git push -u origin <github_branch_name>
来源:https://stackoverflow.com/questions/9526630/adding-an-extra-remote-repository-in-egit