This article shows how to create a new Eclipse project from a remote Git Hub repository. You will learn:
- how to download and install eGit for eclipse,
- how to checkout a Git Hub repository from a remote site and
- how to import a Marven project.
This article assumes that you have the Java EE Kepler version of Eclipse, a Git Hub account that contains a repository that you want to checkout and that the project has a POM file (i.e. is a Marven project).
Download and install eGit for Eclipse.
To install eGit follow these steps:
- Navigate to Eclipse > Help > Install New Software. You will see a dialogue box like the one below.
- In the work with drop down select the Kepler site.
- Then expand the option Collaboration and tick the three option name as follows
- Eclipse EGit
- Eclipse EGit Mylyn GitHub Feature
- Eclipse JGit
- If these options are not available it is because they are already installed
- Click through the rest of the wizard and agree with the licenses. The eGit plug-ins will now be downloaded and installed.
- If you are asked to restart Eclipse do so.
Checkout a Git Hub repository from a remote site
Now we will check out a project from the Git Hub remote server. It is assumed that you have a Git Hub account and a project ready to be checked out. For this part of the article you will need you user name and password for you Git Hub account and the URL of the repository.
- You will need to open the Git Repository Exploring perspective. Navigate to Eclipse > Window > Open Perspective > Others and select the Git Repository Exploring perspective.
- The Git Repository Exploring perspective tab should appear on toolbar next to the Java EE perspective tab.
- Click on the Git Repository Exploring perspective tab. You should see the three options as follows:
- Add an existing local Git repository
- Clone a Git repository
- Create a new local Git repository
- Click the Clone a Git repository to reveal the Source Git Repository dialogue box
- In this dialogue box enter the URL of the repository. This can be found on the home page of the project in your Git Hub account. At the time of writing it was located to the right of the page under the title HTTPS clone URL.
- Copy this URL to the clipboard and paste it into the URI.
- In the authentication section enter you Git Hub username and password and click the Store in Secure Store tick box. Click Next.
- On the this screen we select the master branch (or another branch if appropriate). Click Next.
- Next we select the local destination for the repository. Click Finish.
- Now the repository is checking out to your local computer. This will take a few minutes depending on the size of the project. Once it has finished you will see your repository displayed in the list of Git Repositories.
Import a Marven project.
Now we need to import the project.
- Navigate to Eclipse > File > Import and from the dialogue box that pops up select Existing Marven Project.
- Now you need to select your Marven project. Navigate to the location given above step Local Destination. In the projects section you should see your project. Select it and click Finish.
- The browser will create a new project and import all of the it dependencies. This may take some time. You may see the following dialogue box on the screen while it is preparing the project.
- Once all the dependencies have been imported you can build your project.
This has been a very quick guide to checking out a remote Git Hub project in Eclipse.
Other articles that may be interesting: