Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse + EGit: clone project into workspace

I'm a little confused about how EGit workes.

I have an existing git repository on Github and want to clone it into my workspace. My goal is to have the local repository directly stored inside my workspace-folder but I don't get it working with EGit.

When I want to clone the github repo with EGit, I have to choose a directory as destination. The suggested directory is in my homedir (not in my workspace). When I choose this directory I can see the project in Eclipse but it is not stored in my workspace-folder. Instead it is stored in my home dir.

When I choose a directory directly inside my workspace, later when it comes to import the project it says that there is already a directory with this name.

I don't know how to solve this. I thought this would be a common scenario. In the past I have used hgEclipse (Mercurial) and it was working exactly the way I thought it should be so I'm confused EGit doesn't. Maybe I misunderstood something.

Probably this is important to know: In the github repository there are no .project or .settings files from eclipse. I have them on my .gitignore and so in the import-dialog I have to choose "Import as General Project" and not "Import Existing Projects". But I think this shouldn't matter?

I hope someone can help me or explain me why the EGit plugin doesn't clone the repository directly into the workspace by default.

My Eclipseversion is 3.6, I have installed EGit over the markedplace.

like image 662
Manuel Mauky Avatar asked Jun 18 '11 13:06

Manuel Mauky


People also ask

How do I clone a project directly in Eclipse?

Open Eclipse and choose Import –> Projects from Git (with smart import) Choose the Clone URI option in the Git import wizard and click Next. Confirm the URI, Host and Repository path parameters and click Next. Choose the Git branches to clone from the remote repository and click Next.

How do I use EGit in Eclipse?

Open the Eclipse Import wizard (e.g. File => Import), select Git => Projects from Git and click Next. Select “URI” and click next. Now you will have to enter the repository's location and connection data. Entering the URI will automatically fill some fields.

How do I copy a project to another branch?

In order to clone a specific branch, you have to execute “git branch” with the “-b” and specify the branch you want to clone. $ git clone -b dev https://github.com/username/project.git Cloning into 'project'... remote: Enumerating objects: 813, done.

What is clone submodules in Eclipse?

Submodules are repositories nested inside a parent repository. Therefore when doing a clone of a parent repository it is necessary to clone the submodule repositories so that the files/folders are available in the parent repository's working directory.


1 Answers

As mentioned in this EGit tutorial, the destination directory you mention when importing (cloning) a Git repo is any directory you want, in which the .git will be created:

Import Git Repository

You don't have to select the workspace itself (at least, you should select the workspace/myproject subdirectory, in order to not make the all Eclipse workspace a Git repo.

And you can select any other directory outside the workspace: the Eclipse workspace should only contain meta-data about Eclipse projects and settings.
When declaring a new project, you will be able to select the project directory, making that directory the parent for .classpath and .project.
Your workspace will list that new project, even though it lives outside the workspace.

like image 99
VonC Avatar answered Oct 14 '22 23:10

VonC