I'm trying to create a pull request on GitHub for project "original/QWERTY" so I forked the repo to "Mark/QWERTY". In Eclipse, I already have a repository set up for "original/QWERTY" and that project is in my workspace, named QWERTY.
Now if I create a new repository pointing at "Mark/QWERTY", I'll have two projects with the same name and both Eclipse and me won't like it.
I thought that it should be possible to have a branch or another remote
under a repository and switch between them instead of having two copies (I mean just store the diffs). The problem is that they are different projects on GitHub so I'm not sure how to do it.
What is the correct way to set up two GitHub projects to create a pull request from my fork to the original one in Eclipse with EGit?
Using the information from Rudiger's comment and answer and my trial and error with branches I made my own steps. This picture also helps with terminology.
First, do these 2 things in any order:
master
branch.
origin
(default). configure its fetch if it's not done for you, the default specification is +refs/heads/*:refs/remotes/origin/*
. This ref spec maps all the repo branches to Remote Tracking branches with the same name. If you want to only fetch the master
branch then use +refs/heads/master:refs/remotes/origin/master
.origin/master
and a local branch called master
with configuration of "Remote: origin" and "Upstream Branch: refs/heads/master". You will be working under the local master
as it's the only branch right now.Now you want to be able to push to your fork so you can create PR. You can and already did pull from the original to keep getting updates from other people's work.
fork
(call it whatever you need). Configure its push.
origin
Remote URI points to the original.refs/heads/*:refs/heads/*
. It's easy to work with this spec but you can change it to whatever you need.master
and the branch name is whatever suits what it does. it can be the master
branch or a new branch that let's say fixes a bug, so bug 123
. You do not have a Remote Tracking branch because those are used for pulls. If you also pull from fork
then you will need to configure that in the Remote fork
and get a remote branch.bug 123
(you can see a checkmark next to it). Fix the bug in your code and in the Git Staging view you should see the files changed and the title is <Repository name> [bug 123]
. Make sure you are going to commit/push to the correct branch! Stage whatever you need and commit (adds the changes to the local branch bug123
) and push (creates a branch on the github repo called bug 123
if you stayed with the default spec).Once the PR is merged into the master
branch of the original on GitHubm, you will want to fetch from the master
.
origin
or its fetch "subdir" and choose fetch. The will fetch any changes in all the remote branches because the fetch spec we used maps all the branches (we used the *
character).That's it. Continue to switch to a local branch which maps to your fork based on the updated master
, fix bug, commit and push, create PR, wait for merge into the original, fetch and pull from the original.