Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

eclipse

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?

like image 898
Sastopher Avatar asked Jan 14 '10 08:01

Sastopher


People also ask

How do I share my Eclipse project to GitHub?

With your project open in Eclipse, right-click the project name in Project Explorer and select Team, Share Project... Select Git and select Next. Select Create... from the Configure Git Repository window and choose a folder for your local Git repo. Select Finish.

Where is Git repository in Eclipse?

Step 6: Then again open Eclipse IDE. Then go to Window, then Show View & then others. Step 7: The expand Git folder, click on Git Repositories & Open it.

Can we connect Git with Eclipse?

The Eclipse IDE provides support for the Git version control system. You can easily perform the necessary Git commands like staging, commit, merge, pull and push via the Eclipse IDE. Git is pre-installed in Eclipse IDE. If git is not installed by default, go to Help > Eclipse Marketplace and install git explicitly.


2 Answers

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.

like image 110
Fabian Steeg Avatar answered Oct 20 '22 19:10

Fabian Steeg


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.

like image 21
Sastopher Avatar answered Oct 20 '22 21:10

Sastopher