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 3:10 PM Matthias Sohn <matthias.sohn@xxxxxxxxx> wrote:
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.

Yup, I did the git clone on the command line, storing it in my "~/git" tree.  I set the resulting folder as a git repo in Eclipse, and then did "Import Existing Projects", specifying that location, and deselected the "Copy files into workspace" checkbox.  I note that this is slightly different from the option of the git-specific path of creating a project from a git repo (I don't remember the exact path to get to that).
 
 
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.

Ok, this was very helpful.  My problem was that when I created the remote, I saw that I could either configure it for "Push" or "Fetch".  I figured that since my first logical action will be "Push", I chose "Push", but then after filling that out I couldn't see how to move forward.  In addition, if I try to configure "Fetch" after creating it, it just says that I need to add a mapping, but the default you get when creating it initially is NOT offered, so I would have no idea what to enter.

Now that I've created the remote with the proper Fetch config, I switched to the branch that I created on Github, which prompted me to create a corresponding local branch.  It looks to me like I'm properly set up now so that when I'm ready to push my changes, they will go to the proper branch and fork.

Do you think this experience points out any opportunities for improvements to the docs or process?  Obviously, none of this would be a problem for experienced git users, but it's always useful to look for obstacles that newer users might run into.

For instance, can you think of any reason that someone might create a remote and only (or initially) configure the "Push" config?  From my POV it looked like the obvious first step, but that was obviously wrong.  If there's little to no value in creating a remote with initial "Push" config, perhaps the interface should nudge users away from that path?

It's also a little awkward that you get a nice default mapping when setting the Fetch config initially, but not afterwards.  You could say that an obvious "Quick Fix" option at this point is creating the offered default mapping.


-Matthias


Again, thanks for the help.

Back to the top