开发者

Build EGit repository outside Eclipse workspace

开发者 https://www.devze.com 2023-03-21 15:55 出处:网络
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 r

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. 开发者_C百科


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号