Skip to content

EGit and Eclipse

Aditya Singh edited this page Jan 14, 2018 · 6 revisions

How to Integrate Github Repository with Eclipse

1/13/2018

In this tutorial, I will teach you how to use the EGit plug-in to integrate our GitHub repos with Eclipse. It really isn't that hard.

Install EGit

Make sure you have Eclipse for Java and ALL of the WPiLib plugins enabled. Then, follow these steps:

  1. Navigate in the menu bar at the top Help>Install New Software
  2. Click the "Add" button and enter the following information:

Then there will appear a selection of different plugins. Select all and continue.

  1. Follow the instructions to finish downloading EGit.

Clone a Repository

Now that you have EGit, you need the repository in Eclipse.

  1. Navigate to Window>Show View>Other>Git>Git Repositories
  2. Navigate to Window>Show View>Other>Git>Git Staging
  3. Under the Git Repositories widget, select clone a Git Repository, and for the URL, go to the page of the repository of interest and look for the green button that says "Clone or Download". It will then show you a drop down with a shareable link. That is the link to copy-paste into the Eclipse GitHub import window. After pasting into the window, click "Next".
  4. Making sure all branches are selected, continue and finish importing the project.
  5. The GitHub repository is now within the Git Repository widget, and the code is under "Working Tree folder".

Looking, Fetching, Pulling, and Pushing

Now you can look at the GitHub repository code, and there are some tools that help.

Fetch from Upstream and Pull

To update the repository for any added or modified code, then right click the actual project and select the option "Fetch from Upstream". A window will then appear showing modified files. Select "Ok". Then right click and select "Pull". For some reason there are two "Pull" options, one of which does nothing, so select the bottom "Pull" option.

Then follow the instructions to finish the pull.

Push

To modify or add code, use the "Push" option. This is why you need Git Staging which allows you to stage files to be uploaded. Make sure to save changes you made, and in the Git Staging area under "Unstaged Changes", the file(s) you modified will be there. Select the files you wish to push and click the single green cross which will then stage the files.

You can then add a "Commit Message" and then select "Commit and Push". It may ask for your GitHub account information when pushing, but otherwise there should not be issues.

We figured this out hastily over the span of 30 minutes, and this is probably not the most efficient way. It does however beat copying from GitHub Desktop, modifying, sending a pull request, etc.