Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build EGit repository outside Eclipse workspace

Tags:

egit

I use Eclipse 3.7 and EGit 1.0. If I create repositories inside my Eclipse workspace (as a sub-folder for a project) everything works fine. But obviously this is not recommended so I want to build a repository in a place elsewhere. But this does not work as expected.

I make this steps:

  1. Create a simple Eclipse project with a text file in it (myproject).
  2. Share -> Team -> Git
  3. Create Button -> use c:\user as Parent Directory and mygit as Name
  4. I leave Path within Repository empty
  5. so Target Location is c:/user/mygit/myproject -> Finish

At this point I expect that I can manage my code via EGit. But if I choose the Team menu within the project or text file context menu I see no version control options like commit etc. On the other hand if I delete the created repository the project is also deleted.

Does anybody know how to do this correctly? At first my goal is to build a simple single user repository.

like image 575
TechnoCore Avatar asked Jul 18 '11 14:07

TechnoCore


People also ask

How do I add a repository to Eclipse?

Create a local Git repo for your Eclipse project 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.

How do I clone a Git repository EGit?

Cloning Repositories In order to checkout a remote project, you will have to clone its repository first. 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.


1 Answers

It's quite simple (my setup: Eclipse 3.7, EGIT 1.1.0). The standard layout is to put your project inside (below) a GIT repository, so that you can have more than one Eclipse project in one repository - outside the Eclipse workspace tree.

Then, we first create the repository: In the "Git repositories" view, we create a new (non-bare) repository: For example, in the dialog we fill:

Create a new repository
  • Parent directory: c:\user\gitreps\ (a directory you use to store git repositories)

  • Name : repo1 (your repository name)

This will create c:\user\gitreps\repo1\.git\

After this we share the existing project, which will trigger a physical move:

Take your new project, (no matter where was it created, inside or outside the workspace dir) and share it:

Project (myproj) -> RightClick -> Team -> Share -> Git

In the dialog list select the repositoy you just created (repo1) and leave the rest blank. See that the "Current location" and "Target location" In our example, the "Target location" should be c:\user\gitreps\repo1\myproj

When you press Finish, the project will be physically moved as we want.

like image 147
leonbloy Avatar answered Oct 11 '22 12:10

leonbloy