Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [egit-dev] Looking for help adding reference to fork

On Fri, Nov 20, 2015 at 6:08 PM, David Karr <davidmichaelkarr@xxxxxxxxx> wrote:
I know that this is a "dev" list, not a "user" list.  However, all my attempts to get help with doing something with Egit have failed.  I posted to the EGit forum (https://www.eclipse.org/forums/index.php/m/1715162/#msg_1715162), StackOverflow (http://stackoverflow.com/questions/33816787/how-to-configure-workspace-with-egit-eclipse-so-my-changes-go-to-branch-on-fork), and even the "Java Programming & Eclipse" community on Google+ (https://plus.google.com/117563360070970470465/posts/CGoo91CEKk4).  I did get a couple of short replies to my Egit forum question, but nothing since that.  The only somewhat substantive help I've gotten is from the Git Google+ community, but their primary advice was to forget Eclipse and do it from the command line. As the codebase I'm trying to work on is an Eclipse plugin, I think it's reasonable to try to work as much within this ecosystem as I can.

I've gone through the entire EGit user guide and some of the auxiliary pages.  I'm pretty new to git, but I've used RCS, CVS, ClearCase, Perforce, and SVN in the past.

I have basic understanding of git, and have even managed to get a handful of trivial PRs merged into a couple of projects, although I didn't have to do complicated things with git to get those done.

Now to my problem, which you can read about on the other links, but which I'll rephrase here.

I started looking at a project on github.  I cloned it to my workspace for examination and debugging.  I found a couple of definite changes I wanted to make and prototyped them locally.  I saved off my changes and then stashed my local changes.  I then went to github and forked the original project, and then created a branch, also on github.

Now, I still have the original workspace in Eclipse, which was cloned from the original project.  The projects are referencing the files in my "git" tree, not copied into the workspace.  Now I need to set up my workspace so I can make changes that can get pushed to the branch on my fork.  I did create a remote to my fork with just a push config, but I don't understand what that does for me.

do I get you right that you have the repository including the working tree (the version checked out to the file system) are in one place and the Eclipse workspace is stored somewhere else ?
This should be ok.
 
I'd like to understand the possible options of getting to this point.  I know I could just delete my projects and the git clone and then reclone from my fork and recreate the projects.  I get the feeling that I should be able to simply augment the existing repo through EGit, but I don't understand how to do that.

You cloned the repository from the original project's repository on github. When you cloned the repository a
remote called "origin" was added to your clone's configuration stored in .git/config. So you could now
push the commits you created locally in a local branch e.g. "x" back to the project's original repository
using the remote "origin":
- select your locally cloned repository in the repositories view
- click "Push branch x"
- select remote "origin"
- select the branch on the server side repository you want to push to
- click "next" and then "finish" 

You don't have permission on the original repository in Github so this doesn't work.
But you have permission to push to your fork on Github (another copy of the original repository).
You could push to your fork using 
- select the repository in the repositories view
- click "Remote > Push..."
- select "Custom URI" enter the URL of your fork and credentials and then push your changes

To simplify this you can create another remote e.g. "myfork" (which is just an alias for the URL)
- select "Remotes" under your repositories node in the repositories view
- click "Create Remote..."
- enter "Remote Name" "myfork" and select "Configure Fetch"
- click "Change" and enter the URL of your fork and the credentials, for the "ref mappings" leave the default which maps branches
in your fork (refs/heads/*) to remote tracking branches "refs/remotes/myfork/* which serve as a proxy for the server side branches
- click "save and fetch" to save your new remote including push refspec (defining how to map branches) and fetches changes from your fork to remote tracking branches in your local clone (if there are no new changes in your fork on Github nothing will happen so if this is the first time you can
also just click "save" and skip fetching.

Next time you want to push to your fork you can just click "Push branch" select remote "myfork" and target branch to push the currently checked out branch to the selected branch in your fork.

-Matthias


Back to the top