Copy the URL from GitHub and select in Eclipse from the menu the
File → Import → Git → Projects from Git
If the Git repo isn't cloned yet:
In> order to checkout a remote project, you will have to clone its repository first.
Open the Eclipse Import wizard (e.g.
File => Import), select
Git => Projects from Git and click
URI” and click
Now you will have to enter the repository’s location and connection data. Entering the URI will automatically fill some fields. Complete any other required fields and hit
Next. If you use GitHub, you can copy the URI from the web page.
Select all branches you wish to clone and hit Next again.
Hit the Clone… button to open another wizard for cloning Git repositories.
Original answer (July 2011)
First, if your "Working Directory" is
C:\Users, that is odd, since it would mean you have cloned the GitHub repo directly within C:\Users (i.e. you have a
.git directory in
Usually, you would clone a GitHub repo in "
any directory of your choice\theGitHubRepoName".
As described in the EGit user Manual page:
In any case (unless you create a "bare" Repository, but that's not discussed here), the new Repository is essentially a folder on the local hard disk which contains the "working directory" and the metadata folder.
The metadata folder is a dedicated child folder named "
.git" and often referred to as "
.git-folder". It contains the actual repository (i.e. the Commits, the References, the logs and such).
The metadata folder is totally transparent to the Git client, while the working directory is used to expose the currently checked out Repository content as files for tools and editors.
Typically, if these files are to be used in Eclipse, they must be imported into the Eclipse workspace in one way or another. In order to do so, the easiest way would be to check in .project files from which the "Import Existing Projects" wizard can create the projects easily. Thus in most cases, the structure of a Repository containing Eclipse projects would look similar to something like this:
See also the Using EGit with Github section.
My working directory is now
You should have the content of that repo checked out in
c:\users\projectname (in other words, you should have more than just the
So then I try to import the project using the eclipse "import" option.
When I try to import selecting the option "Use the new projects wizard", the source code is not imported.
That is normal.
If I import selecting the option "Import as general project" the source code is imported but the created project created by Eclipse is not a java project.
When selecting the option "Use the new projects wizard" and creating a new java project using the wizard should'nt the code be automatically imported ?
No, that would only create an empty project.
If that project is created in
c:\users\projectname, you can then declare the eisting source directory in that project.
Since it is defined in the same working directory than the Git repo, that project should then appear as "versioned".
You could also use the "Import existing project" option, if your GitHub repo had versioned the
.classpath file, but that may not be the case here.