I am a typical Eclipse/Subversion user beginning the migration to Git. I've researched the basic concepts of git and have decided to stick to a one project per repository approach initially to keep things simple. I am still having trouble, though, deciding where to place the repository for each project.
I have spent a lot of time reviewing the answers to this question, although I believe the author of that question was assuming that you can only use Eclipse to manage the repository if the repository is located within the Eclipse workspace, which is, of course, not true.
The thing that struck me most about that question, though, was the fact that all but one answer (including the accepted answer) suggested keeping the repository inside the Eclipse workspace, whereas only one answer pointed out that the EGit User Guide recommends the exact opposite.
It would appear in practice, however, that there are a number of approaches implemented by Eclipse/EGit, some of which seem to contradict the EGit recommendations.
For example, if you use the New Project Wizard to create a New PHP Project from Git and the repository is remote, Eclipse/EGit will happily create a project folder in the Eclipse workspace and put the repository (.git) in the project folder. This is the end result that I actually want, as it keeps everything encapsulated within the Eclipse workspace.
However, if you use the New Project Wizard and select a Git repository that is local, Eclipse/EGit doesn't clone the repository like it does for remote repositories. Instead it uses the working copy of that repository as the project location, creates its .project and other meta stuff in that location and also creates a new (seemingly unnecessary) folder within that working copy with the same name as your project (so you end up with, for example, ~/git/blah/blah
). If you delete that superfluous folder you end up with a structure that is identical to the first example, the only difference being that the project folder is not a sub-folder of your Eclipse workspace folder, it is somewhere else on your file system (eg. ~/git/blah
). The only positive thing this approach seems to have going for it is that it adheres to the recommendations in the EGit User Guide, but from a technical perspective, its hard to see how this is really all that different to the first example.
Given these puzzling observations, I'm wondering what sort of experiences people have had using each of these approaches and what the pitfalls might be if one ignores the recommendations in the EGit User Guide.
As the git repository is contained inside your work directory, just place the work directories wherever is most convenient.
The repository is essentially the . git hidden folder inside the working directory (workspace). The working directory (workspace) is essentially your project folder.
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.
The workspace allows you to work on related projects together. It is pretty much up to you to decide how to organize the projects in your workspaces. A workspace provides a default location to store all projects, but doesn't require that they are stored there.
The implications of both solutions are listed directly in the user guide that you linked. I can tell you that the part
This can result in performance issues
is unfortunately very true. So if you have a git directory with a huge number of files inside your workspace, many git operations will start with a "counting objects..." dialog that blocks your IDE because it scans all files in the workspace. For my current 20000 files this means waiting 10 to 20 seconds for every commit, every switch, ...
In spare time activities, where I can fortunately use the other alternative (having the git working directory outside the workspace) everything feels much snappier and it is fun to merge and switch.
So if you go for large projects, consider the git directory outside the workspace as first choice.
I am doing the same migration as the original poster and have found another thread where the same doubts are expressed on the Egit recommendation: Should I store git repository in Home or Eclipse Workspace?
@JamesG So this is your layout?
~/projectA/workspace/.metadata ~/projectA/workspace/subproj1/.project ~/projectA/workspace/subproj2/.project ~/projectA/subproj1/.git ~/projectA/subproj1/file1 ~/projectA/subproj2/.git ~/projectA/subproj1/file2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With