In this tutorial I will show the basic steps of creating Java project in eclipse using EGit plug-in. Eclipse “Helios” and EGit version 0.8.4 are used in this tutorial.
Install EGit plugin
Start eclipse. Go to Help -> Install New Software… In the “Work with” select “All Available Sites”. And then in the search box enter git. You will see the following picture:
Select “Eclipse EGit (Incubation)”:
Click Next. Eclipse JGit plugin will be installed automatically as a dependency of EGit plugin:
Press “Next”, accept the terms of the licence agreement:
press Finish and after some time plugins will be installed. Restart eclipse.
Import Git repository and create new project
After eclipse is restarted select File -> Import…, and you will see the new category: Git. Expand it and select “Projects from Git”. Press next.
The next window will ask you about Git repository location. You can see two buttons there: Clone and Add. Add button should be used when you already have a local copy of Git repository. If you don’t have such copy, you need to press Clone button.
In this tutorial we will import remote Git repository, i.e. at this moment we do not have a local copy of this repository on our hard drive. The Git repository which we are going to import has been already created on github.
So, press Clone button and enter all location parameters. If you go to the github project properties, you can select what protocol are you going to use. I have selected https. Here is an example (if you just copy and past url from github to URI field all other fields, except password, should be filled out automatically):
If all parameters are correct, after pressing Next button you will see the branch selection window. In my case I do not have any branches, therefore I just press Next and select where the local copy of the Git repository will be stored. And here is the problem. You should save the copy of your Git repository in the same folder where you plan to create eclipse project. If you save Git repository in another folder, you will not be able to “share” your project with that repository. There is a solution which solves this problem, but we will talk about it later.
After that select just added Git repository and press Next button:
and “Import Projects from Git” window will appear. As we are going to create new project select “Use the New Projects wizard” and press Finish.
Now we will create new Java Project using default parameters:
and here it is:
We can see the name of eclipse project (“eclipse_git”), name of Git repository (“eclipse_git”) and repository branch (“master”).