How do I create a git repository over an eclipse project or vice versa?

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?

  • Git FileRevision get comment with multiple lines - gets only first line
  • Working with Eclipse .classpath and project files in Git?
  • Eclipse Git Error: Error occurred computing diffs
  • “git pull --rebase” in Eclipse
  • Creating a new root directory in an Eclipse project under version control
  • Linking bare repo to actual repo in Git and post-receive hooks
  • Git / Mercurial : Separate repos in structure
  • Rebase on the root and keep empty commits
  • What does “changeset stripped” mean?
  • Remove files from the staging area
  • Force git to manual merge even in “obvious” situations
  • Git between multiple projects
  • 2 Solutions collect form web for “How do I create a git repository over an eclipse project or vice versa?”

    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.

    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.

    Git Baby is a git and github fan, let's start git clone.