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

looks like you never fetched from your fork. When you run fetch it will download new commits from the respective
remote repository and create remote tracking branches for all branches present in the remote repository.
This is configured in .git/config, a typical remote configuration looks like this

[remote "origin"]
url = "" href="https://git.eclipse.org/r/egit/egit.git">https://git.eclipse.org/r/egit/egit.git
fetch = +refs/heads/*:refs/remotes/origin/*

this instructs git to fetch from https://git.eclipse.org/r/egit/egit.git when your run "git fetch origin"
and will map the remote branches (left hand side of the "fetch =" line) to the remote tracking branches
named like the name "origin" of the remote you are fetching from.

There are basically 3 different types of branches:

- local branches: used to track commits you create locally, local branches typically move when you create a commit,
  checkout another branch or reset a branch to a different commit
- remote branches: branches in another repository you may have configured a remote for in your local clone
- remote tracking branches: reside in your local clone and act as proxy for the corresponding remote branches, they
  only move as result of a fetch command, which first downloads new commits from a remote repository and then
  updates the corresponding remote tracking branches. This has the effect that immediately after the fetch they
  are in exactly the same state as the corresponding remote branches they mirror. This allows you to compare your
  local branches against remote branches in your local clone.

-Matthias

On Tue, Nov 24, 2015 at 8:32 AM, David Karr <davidmichaelkarr@xxxxxxxxx> wrote:


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.
 
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.

After properly configuring the remote, I was able to commit and push the changes to the branch on my fork.

Now, I'm attempting to merge the changes in the branch back to the master on my fork.  I thought this would be straightforward, but I'm realizing I don't know how to do this.  Specifically, I don't know how to "switch to" the master branch on my fork.  When I select "Switch to", I can see "master", but it's the "original" master, from the project I cloned from. I don't see how, at least within EGit, to switch to the master branch on my fork.

In fact, I didn't realize this until after I had merged the changes from my fix branch to the master and then tried to push them out, when it obviously told me that I didn't have permission to push to that repo.

Note that I wrote a couple of additional questions on the egit forum, although about different minor issues than I'm relating here.

-Matthias



Back to the top