Adding an extra remote repository in EGit

末鹿安然 提交于 2019-12-07 09:30:15

问题


I have 3 different git repositories:

  1. An open source project
  2. My own fork of the project on GitHub, which was forked from 1.
  3. 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.


回答1:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!