Git Extensions and Eclipse

June 2016: I’ve stopped using GitExtensions because I no longer need to use Windows. I use Linux for everything and Git is built in.

Jan 2015. This document explains how to get Git Extensions working with Eclipse.

Git Extensions is a very handy Windows GUI for Git. I find it easier to use and more general than EGit (git for Eclipse).

In particular, this is looking at using GitExtensions and Eclipse with the First Robotics Java packages.

There are three types of installations that can be considered:

  1. installing Git Extensions and Eclipse (e.g. on a desktop at home where you code and push programs to GitHub)
  2. doing the same as #1. but wanting to have the FRC templates work (e.g. on a desktop at home)
  3. doing the same as #1 and #2, but wanting to compile and upload the code to the roboRio (e.g. on a laptop that will send the code to the roboRio).

I’ll be looking at #3. A few steps can be simplified if you just want to do #1 or #2.


I. Install Git Extensions

II. Install Eclipse

For installations of type #2, and #3, follow the instructions at wpilib.screenstepslive.com. (It says that you need to install the C++ version – presumably because some of the scripts used to build and upload the jar files are in C++.)


III. Make a test project in Eclipse

This is to see where the Eclipse workspace is. In the example shown, my workspace is in …\user\workspace

caption here

Locating Eclipse workspace (by making a temporary project)

screen2 screen3

So, you can see that “testing” has been created and where it is located.


IV. Clone the GitHub repository

1. First get the repository URL from the GitHub page (see red circle)
2. Then click on “Clone Repository” — NOT “Clone GitHub repository”
3. Paste in the URL of the repository.

aaa
4. Then make sure that you type in exactly the correct workspace location. It will fill in the correct subdirectory automatically, but check to make sure it’s correct.
5. Click on the “Clone” button.
5b. After this there will be a success message, click OK.
5c. It will say “Do you want to open the new repository ____ now?” Click “Yes” to see the screen below.

screen6
6. You’ll now see Git Extensions showing the repository with its branches and commits.


V. IMPORT the git project into Eclipse.

1. Start Eclipse if it is not already running.

screen7
2. Click on “File\Import”, then “Import projects from Git”

screen8
3. Choose “Existing Local Repository”

4.If the new repository does not show up there, then click on the ADD button and find it. (I just had to navigate to the C:\Users\user\workspace folder, and it automatically found the new git repository that I put there via Git Extensions.)
screenx
Oops! I highlighted the wrong one in this screen shot.

5. After this it automatically started the Wizard thing. If it doesn’t there will be a button to select it.
screen9
6. Choose “Robot Java Project”

7. When you create the new project via the wizard, it is VERY IMPORTANT to make sure that the next three options are correct (project name, package, and whether it is command based or iterative).
screen10

screen11
8. Voila! There it is!


VI. Finally, you can delete the “testing” project.

screen12


In conclusion, some tips about Git:

  • Use Gix Extensions to change (checkout) branches
  • In Eclipse, the current branch is shown next to the project name. Cool!
  • To download changes, etc. from GitHub do a “Fetch” then a “Merge”.
  • To upload your code to GitHub, do a “commit” then “push”
  • NEVER do REBASE
  • NEVER do a FORCED PUSH (it will wipe stuff out and can’t be recovered from)
  • NEVER push to the Master branch. Make your own branch off of master or development and work on that.