Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I store git repository in Home or Eclipse Workspace?

Tags:

java

git

eclipse

I'm just moving from svn to git, and am keen to lay some good foundations.

By default Eclipse wants to store my local clone repository in ~/git. I'm more comfortable keeping all data for a task in the same workspace - so I'm inclined to keep it in my workspace.

Are there any significant pros/cons I should consider?

I don't intend doing a lot of branching - I'm really going down the dvcs route mostly to overcome some unreliable internet comms issues.

like image 699
ianmayo Avatar asked Oct 07 '11 09:10

ianmayo


People also ask

Where should I put my git repository?

As the git repository is contained inside your work directory, just place the work directories wherever is most convenient.

What is the difference between repository and workspace?

The repository is essentially the . git hidden folder inside the working directory (workspace). The working directory (workspace) is essentially your project folder.

Where should I put my Eclipse workspace?

You can place it anywhere you want. It doesn't matter. I have mine placed in my secondary hard drive on the laptop under Android and Workspace. You could always just use the default it gives you.

What should be the Eclipse workspace?

It defines your area of interest during an Eclipse session. In a workspace you define projects that reference your disk resources. You don't have to move source files into the workspace. And projects don't import or copy source files into the workspace. Instead projects point to any folder or files on your disk.


2 Answers

I'm too switching to Git in Eclipse, and reading about this issue. It seems that current wisdom (though not everyone agrees) is:

  • Get used to NOT having your projects below the workspace directory.

  • Have one git repository for each group of related eclipse projects (and perhaps more files, of course). The concept of "related projects" is up to your convenience [*]

  • For each repository, one first level directory for each Java project. This implies that you'll have a .git/ directory, and, at the same level, the project directories.

Example: suppose that, "before GIT", you had one eclipse workspace with several projects:

/wk/workspace/.metadata/   /wk/workspace/projXXX/   /wk/workspace/projXXXtest/  (related with the previous) /wk/workspace/projYYY1/     | /wk/workspace/projYYY2/      >  three related projects /wk/workspace/projYYY3/     | /wk/workspace/projZ/        (a project you are not going to version in git) 

Then you'll create two empty directories, one for each repository, say:

~/repositories/XXX/  ~/repositories/YYY/  

and afterwards, with the new GIT layout, you'll have:

/wk/workspace/.metadata/   /wk/workspace/projZ/   ~/repositories/XXX/.git/   (XXX related repository - non-bare) ~/repositories/XXX/projXXX/ ~/repositories/XXX/projXXXtest/  ~/repositories/YYY/.git/   (YYY related repository - non-bare) ~/repositories/YYY/projYYY1/ ~/repositories/YYY/projYYY2/ ~/repositories/YYY/projYYY3/ 

Eclipse (EGit) does all this for you when you click Team->Share over an existing project and specify (in the example) ~/repositories/XXX/.git/ as repository, (~/repositories/XXX/ as "Working directory", leave "Path within repository" blank).

[*] Bear in mind that here each group of projects is, from the Git point-of-view, just a set of directories inside a repository. Some relevant implications: in the above example, you'll never have in the Eclipse workspace two different branches/versions of projects projYYY1 -projYYY2 simultaneously; and, say, when you tag a project commit, you are actually tagging the full repository (group of projects) commit.

like image 59
leonbloy Avatar answered Sep 24 '22 12:09

leonbloy


The .git should be where your working tree is (that is the files representing the current HEAD of the current branch you are working on)

Remember that with Git, branches are not directories (as opposed to SVN), so your working tree will represent directly a branch content, not several directories (for your various branches), followed by a content per branch.

I usually like to keep my project sources separate from my Eclipse workspace, but that is a matter of preference.

like image 32
VonC Avatar answered Sep 23 '22 12:09

VonC