[eclipse] Importing a GitHub project into Eclipse

I've imported a GitHub project but how do I setup the project in my Eclipse project workspace?

Do I need to set the GitHub working directory(c:\users) to my Eclipse working directory(c:\Projects) prior to checking out the project ?

enter image description here

Edited :

My working directory is now c:\users\projectname\.git 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, 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 ?

enter image description here

This question is related to eclipse github

The answer is


It can be done in two ways:

1.Use clone Git

2.You can set it up manually by rearranging folders given in it. make a two separate folder 'src' and 'res' and place appropriate classes and xml file given by library. and then import project from eclipse and make it as library, that's it.


I think you need to create a branch before you can import into your local Eclipse, otherwise, there is an error leading to incapable of importing repository from Github or Bitbucket.


Using the command line is an option, and would remove the need for an Eclipse Plugin. First, create a directory to hold the project.

mkdir myGitRepo
cd myGitRepo

Clone the desired repository in the directory you just created.

git clone https://github.com/JonasHelming/gitTutorial.git

Then open Eclipse and select the directory you created (myGitRepo) as the Eclipse Workspace.

Don't worry that the Project Explorer is empty, Eclipse can't recognize the source files yet.

Lastly, create a new Java project with the exact same name as the project you pulled. In this case, it was 'gitTutorial'.

File -> New -> Java Project

At this point, the project's sub directories should contain the files pulled from Github. Take a look at the following post in my blog for a more detailed explanation.

http://brianredd.com/application/pull-java-project-from-github


I encountered the same problem, and finally found a way:

  1. Add or create git repository in git view.
  2. Click new java project menu, uncheck "use default location", select the git repo location, click finish.

Ecplise Version: Mars.2 Release (4.5.2)


When the local git projects are cloned in eclipse and are viewable in git perspective but not in package explorer (workspace), the following steps worked for me:

  • Select the repository in git perspective
  • Right click and select import projects

With the last ADT, you can import Github project using Eclipse :

  1. File -> Import -> Git -> Projects From Git > URI

  2. Enter the Github repository url

  3. Select the branch


unanswered core problem persists:

My working directory is now c:\users\projectname.git 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, 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 ?

Yes it should.

It's a bug. Reported here.

Here is a workaround:

  • Import as general project

  • Notice the imported data is no valid Eclipse project (no build path available)

  • Open the .project xml file in the project folder in Eclipse. If you can't see this file, see How can I get Eclipse to show .* files?.

  • Go to source tab

  • Search for <natures></natures> and change it to <natures><nature>org.eclipse.jdt.core.javanature</nature></natures> and save the file

    (idea comes from here)

  • Right click the src folder, go to Build Path... and click Use as Source Folder

After that, you should be able to run & debug the project, and also use team actions via right-click in the package explorer.

If you still have troubles running the project (something like "main class not found"), make sure the <buildSpec> inside the .project file is set (as described here):

<buildSpec>
    <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
</buildSpec>