EGit - hpgDesigns/hpgdesigns-dev.io GitHub Wiki
EGit is the Git plugin for Eclipse. It's use is not very intuitive, so we provide instructions here on how to install and use it for the purposes of our projects.
Install
Installation of EGit is generally done through Eclipse. Because of this, the steps may vary, depending on which version of Eclipse you installed.
Generally, run Eclipse (if you don't already have it running), and go to Help > Install New Software (or Help > Software Updates). In older versions of Eclipse, you may then need to click the Available Software tab.
In the Work With box, select what should probably be the only option listed, named something like "Indigo - http://download.eclipse.org/releases/indigo" or whatever your Eclipse version is named. Give it a moment to update the list of software.
At this point, you can either scroll down to find the "Collaboration" section, or else, in the search bar (between Work With and the software list), type "EGit" and press enter, then give it a good moment to update the list and find items by that name. You'll probably see the "Collaboration" section as the only item listed.
Expand Collaboration (or whatever sections it finds), and find one named "Eclipse EGit", and check it. You do *not* want stuff with Mylyn in its name unless you know for a fact that you have Mylyn installed (even if you do have it installed, it does not hurt to keep them deselected, it just means that Mylyn won't be able to add special mylyn features to EGit).
Click Next, and follow the rest of the wizard. Agree to the license, etc. Feel free to let Eclipse restart itself after it's done.
Now, assuming no errors popped up, you should have EGit installed and ready to use.
Checkout
To checkout (clone) a project once you have EGit installed, follow these
steps. You will need the repository's HTTP URI to its git file, which
you can usually obtain by visiting the repository. For example, github
projects will usually have a URI of the following form:
https://github.com/Owner/Project.git
Note 1: These instructions are only designed for Java projects. For non-java projects, you are on your own. Try consulting the building instructions for the non-java project instead. Notably, step 5 (and substeps) will differ.
Note 2: This will create a valid git directory which you may interact with using git via command line if you do so desire, so checking out via command line is entirely unnecessary.
- File > Import
- Git > Projects from Git (if you don't see this option, EGit probably didn't install correctly. Go back and try again) > Next
- Clone (top right corner. Opens a new wizard). In some versions,
instead you will want to choose "URI" and click Next.
- Input the HTTP URI, and ensure that the remaining information is filled out correctly. Port is optional. If you don't have credentials to the repository, you can also omit User and Password, and you will get a read-only[1] copy of the repository > Next
- Select all branches to clone (this is only to ensure that we are doing a *full* clone. We select our desired branch in the next step) > Next
- Select a directory to store the code locally, the desired branch, and a desired Remote name (origin is usually sufficient) > Next
- If it asks about Gerrit Code Review, we're not interested in it (unless you are, in which case, good luck). Just click Finish.
- In some versions, you may need to select the newly cloned project > Next
- Use the New Projects wizard (makes the tree disabled) > Finish
- Select Java Project > Next
- Name the Project. Deselect "Use the default location" (disables most of the rest), and locate the directory that you just cloned to.
- Finish (the rest of the stuff is uninteresting, and we can set it up later if we care).
- Our first wizard will do some magic and then go away. You are done!
If you make changes to the project with the command line (e.g. with command-line git), Eclipse might not recognize them right away. This can easily be resolved by Refreshing the project (Right click on the project, and click Refresh. F5 is the shortcut key, so you can alternatively simply click on the project and press F5).
- A read-only repository means that you can still make changes to your local repository, but you cannot push those changes to the remote repository.