tags:

views:

64

answers:

2

Hi. I have a git repository that is just a directory tree (/myprogram/src/com/mycompany/test) with some source files. I wish to create an eclipse project around this repository. Both orders of create project in eclipse and git clone <url> <myprogram> from the command line give me a "folder already exists" error from whatever tool I use last. I could move the files manually to merge them, but it feels messy and I'm not 100% confident I know which files to touch.

How is this supposed to be done properly?

+2  A: 

You could do it by selecting Import -> Existing Projects into Workspace, select the directory containing your project (the parent of myprgram), and check the checkbox next to your project (myprogram).

To have Git support in Eclipse, install eGit and then right-click your project, select Team -> Share Project -> Git, expand the triangle to select the existing repository and click Finish. This should give you Git annotations on your project.

Another option might be to just select Import -> Git -> Git Repository (after eGit is installed) and import your repository (but I've never done that with a local repository). See also the eGit user guide.

Fabian Steeg
Thanks for pointing me to eGit. It's really handy and I'll probably end up using it, but none of your solutions resolve my problem. The source files attached to the repository are not actually a project yet, so there is no way to import it into the workspace as a project.Your second suggestion creates a repository out of an existing project. This is not what I want. I want a project created around a git repository, not a repository out of a project.Your third suggestion gives me a "<project folder> is not an empty directory" error, the same error I was initially struggling with.
Sastopher
A: 

To resolve this I just ended up copying the git repository into a newly created project, but upon revisiting the issue I found a link here that suggests something slightly more elegant (but functionally similar).

After creating a new project, use Import -> Filesystem and Select All. In my case, my repository already had a proper /src/com/... directory structure which merged nicely into the one set up by the new eclipse project.

Sastopher