Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Eclipse Workspace directory and ".git" directory
Eclipse Workspace directory and ".git" directory [message #1816959] Tue, 12 November 2019 22:59 Go to next message
L C is currently offline L CFriend
Messages: 14
Registered: January 2019
Junior Member
Hi,

Is it proper to have ".git" directory under Eclipse workspace directory or under respective projects directories? I ended up with two ".git" directories, each under respective project (see below):

Working directory (Eclipse workspace)
|
|-.metadata
|
|--Project1
|  |-- .git
|  |-- .classpath
|  |-- .project
|  |-- ....
|
|--Project2
|  |-- .git
|  |-- .classpath
|  |-- .project
|  |-- ....


My Git remote repository looks like this:
# ls -l /var/lib/git
total 8
drwxr-xr-x 8 luser luser 4096 Nov  9 07:26 Project1.git
drwxr-xr-x 8 luser luser 4096 Sep 12 16:20 Project2.git


My setup appears to contradict the documentation ( see https://wiki.eclipse.org/EGit/User_Guide#The_longer_story. ) but it does work.

Any ideas? Potential problems? Thanks

[Updated on: Wed, 13 November 2019 13:12]

Report message to a moderator

Re: Eclipse Workspace directory and ".git" directory [message #1816991 is a reply to message #1816959] Wed, 13 November 2019 13:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30685
Registered: July 2009
Senior Member
That looks to me like you've made each project also be directly a clone/repository. It's more typical to put many projects in a single clone. I.e., you didn't create two folders in a single clone, you created two clones and made the root folder be a project.
Re: Eclipse Workspace directory and ".git" directory [message #1816995 is a reply to message #1816991] Wed, 13 November 2019 14:08 Go to previous messageGo to next message
L C is currently offline L CFriend
Messages: 14
Registered: January 2019
Junior Member
The way I did it, if I remember correctly, is by cloning Project1 and Project2 from the remote repository and then importing them into Eclipse, that is:

(Work is the Eclipse workspace directory)
# cd Work 
# git clone /var/lib/git/Project1.git
# git clone /var/lib/git/Project2.git
(... and then import Projet1 and Project2 into Eclipse)


Any problems with the above? Thanks

[Updated on: Wed, 13 November 2019 15:04]

Report message to a moderator

Re: Eclipse Workspace directory and ".git" directory [message #1817000 is a reply to message #1816995] Wed, 13 November 2019 15:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30685
Registered: July 2009
Senior Member
That looks like two clones. Whether that's a problem in the eye of the beholder. It's different from what's shown for https://wiki.eclipse.org/EGit/User_Guide#The_longer_story where there is a single repository with two projects (which are subfolders in the clone folder).
Re: Eclipse Workspace directory and ".git" directory [message #1817014 is a reply to message #1816991] Wed, 13 November 2019 22:59 Go to previous messageGo to next message
L C is currently offline L CFriend
Messages: 14
Registered: January 2019
Junior Member
Ed Merks wrote on Wed, 13 November 2019 13:29
That looks to me like you've made each project also be directly a clone/repository. It's more typical to put many projects in a single clone.


I didn't do it this way because I thought putting several unrelated project directories into the same clone may lead to problems:

1. If the developer is planning to work on one particular project then cluttering the local working directory with projects that have nothing to do with that work doesn't sound like such a great idea. Those unrelated project files would just be taking up space, getting in the way and creating a potential for something to be changed by mistake.

2. Depending on the number of unrelated projects in the clone and their size, the clone may take a considerable amount of disk space and time necessary to copy all that stuff.

Thoughts? Thanks
Re: Eclipse Workspace directory and ".git" directory [message #1817016 is a reply to message #1817014] Thu, 14 November 2019 05:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30685
Registered: July 2009
Senior Member
Yes, it makes sense to put unrelated things in separate clones.

I see each of your projects has a .classpath file so I assume each is a Java project. It seems to me only the most trivial Java software is ever developed as a single project. Given you've made the root folder of the clone itself a project you'll never be able to add another project to the clone as your software grows in complexity. Well, technically you can, but there's no such concept as a nested Eclipse project, so you'd end up with something that doesn't fit well with the workspace concept of a project, i.e., you'll end up with a project that has a folder that is also itself a project so you'll see the same files twice in the workspace unless from the context menu you use Properties... -> Resource -> Resource Filters... to hide subfolders of a project from the workspace's view of that project, i.e., you could use that to hide the .git folder so that you don't accidentally edit it directly and so that the workspace doesn't index it or need to synchronize the state of the entire clone representation as part of the workspace's state.

It seems to me that you'd likely be better off with the project being a subfolder in the clone; then you could more easily add, for example, a JUnit project, or refactor the project into small related parts.
Re: Eclipse Workspace directory and ".git" directory [message #1817045 is a reply to message #1817016] Thu, 14 November 2019 15:41 Go to previous messageGo to next message
L C is currently offline L CFriend
Messages: 14
Registered: January 2019
Junior Member
Ed Merks wrote on Thu, 14 November 2019 05:01
Yes, it makes sense to put unrelated things in separate clones.

It seems to me that you'd likely be better off with the project being a subfolder in the clone; then you could more easily add, for example, a JUnit project, or refactor the project into small related parts.


How would the remote repository structure look in this case? Something like the following, perhaps?

/var/lib/git/WorkTeam1.git/
/var/lib/git/WorkTeam1.git/Project1/
/var/lib/git/WorkTeam1.git/Project2/
/var/lib/git/WorkTeam1.git/Project3/

/var/lib/git/WorkTeam2.git/
/var/lib/git/WorkTeam2.git/Project4/
/var/lib/git/WorkTeam2.git/Project5/ 


and then:

# git clone /var/lib/git/WorkTeam1.git


Thanks
Re: Eclipse Workspace directory and ".git" directory [message #1817077 is a reply to message #1817045] Fri, 15 November 2019 07:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30685
Registered: July 2009
Senior Member
Yes.

Here's how EGit's repository is structured:

https://git.eclipse.org/c/egit/egit.git/tree/

They've also made the root be a project, no doubt so that they can edit the files at the root via the workspace. (And they've not added filters to the root .project no doubt because most people don't know about how helpful those things are.)
Re: Eclipse Workspace directory and ".git" directory [message #1817108 is a reply to message #1817077] Fri, 15 November 2019 14:56 Go to previous messageGo to next message
L C is currently offline L CFriend
Messages: 14
Registered: January 2019
Junior Member
Thanks.
Re: Eclipse Workspace directory and ".git" directory [message #1817133 is a reply to message #1817077] Fri, 15 November 2019 20:56 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 174
Registered: August 2016
Senior Member
Ed Merks wrote on Fri, 15 November 2019 07:51

They've also made the root be a project, no doubt so that they can edit the files at the root via the workspace. (And they've not added filters to the root .project no doubt because most people don't know about how helpful those things are.)


Yes. Though personally I've never needed that; I can edit those files well enough through the working tree in the git repositories view.

I'm not sure I understand the parenthetical remark, though. You mean exclude filters for all the projects within?
Re: Eclipse Workspace directory and ".git" directory [message #1817143 is a reply to message #1817133] Sat, 16 November 2019 06:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30685
Registered: July 2009
Senior Member
Yes, one can generally edit files from the working tree directly so that's really great. It's less than ideal that there is no "Open With ->" just "Open in Editor" so one can't directly control which editor is opened as one can for a workspace resource. And of course things like Search -> File will not find things in the working tree, but generally Eclipse projects don't tend to keep so many important things in the root that need frequent editing...

Yes, exclude filters is a little-used feature that's extremely useful. I used Eclipse for 15 years without knowing this existed. :-P So I assume that many other people, even very experience ones, might not know about it as well. No offense intended!

It could (it's not necessary and I'm not even saying it should) be used to exclude all the nested project folders from the root project; i.e., it could use a pattern like org.egit.* to exclude all the "nested" projects such that you could (if you wanted to) import this root project into the workspace without ending up with a bunch of "duplicate" files (which is annoying when you do a Search -> File). We use this for example with Oomph to exclude the target folder (the one populated by local Maven/Tycho builds) from the workspace view of each project; this saves lots of indexing overhead and avoids searches finding derived artifacts from the Maven build.
Re: Eclipse Workspace directory and ".git" directory [message #1817171 is a reply to message #1817143] Sun, 17 November 2019 19:26 Go to previous message
Helen Keller is currently offline Helen KellerFriend
Messages: 52
Registered: June 2019
Member
I just run into an odd "problem" - after I "import" from local repository , the project behaves OK until I add a plain C/C++ test project.
Then doing "Build -> Settings " on such test project works only once.
I ended up with "Eclipse_CDT" and "Eclipse_CDT_TCF_EGIT" folders and corresponding workspace folders.
For "ease of navigation" I could put them as sub folders of some common folder.

Similar to your cases of multiple local repositories.

From past experiences with different versions of Eclipse I prefer to be "disorganized " and keep functional folders separate.
When Eclipse goes to next version /release I will put all current v ersion under common folder then copy them to archive.
I am little paranoid of loosing stuff, been there , done that.

Cheers



Previous Topic:Eclipse project makefile versus cloned makefile
Next Topic:Synchronize - basic questions
Goto Forum:
  


Current Time: Sun Dec 08 02:24:03 GMT 2019

Powered by FUDForum. Page generated in 0.09773 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top