Honestly sometimes I’m not sure why I continue to persist in using Eclipse as my editor of choice for most projects. Maybe it’s that I’ve been using it for so long now (7 years) and it’s gone the distance for me, though as with any long term relationship there are fights. Today was one of those fights, as I attempted to import a remote Git repository and create a project for it on a Windows development machine.

The Problem

The problem I kept running into wasn’t so much how to import/clone the remote repository, as it was how to attach an Eclipse project to it. It seemed like no matter what I did I ended up stuck at one of the following dead-ends:

  • Repository cloned and listed in the Git Repository view, but ‘importing’ it left me with an empty, non-revisioned project.
  • Or, attempting to create a project within the locally cloned Git repository would create the project one directory level down within the Git repository, so none of the repository files were actually within the project.

Extremely frustrating situation!

The Solution

The solution I happened upon (and perhaps there are more, or better ways of doing this, if so, I’d love to hear them in the comments below), was to do the following:

  1. Clone the Repository This can easily be done by switching to the Git Repository view and clicking the ‘Clone Repository’ button. This will clone the remote Git Repository into, for instance C:Usersusernamegit
  2. Create the Project Create a project with the New Project wizard, and uncheck the ‘Use default location’ option, selecting the above local Git repository as the project Location.
  3. Share the Project At this point if you’re following along you should have a locally cloned Git repository, and an unrevisioned Eclipse project containing the repository files. Right-click on the project directory within Eclipse and click Team > Share project…
  4. Select ‘Git’ and click ‘next’
  5. Check “Use or create repository in parent folder of project”
  6. In the subsequent screen you should see your cloned repository listed and checked
  7. Click ‘Finish

Now you should be able to Push your locally commited changes to the remote origin repository, and Fetch/Merge changes down.

Published by Justin Stern

Justin is one of our co-founders, and is our resident overengineer. He likes to write developer tutorials and make black magic happen in our plugins. He thinks that writing code is a lot easier than writing words.