git, egit, submodules, and symlinks -- how should shared sub-projects be handled in eclipse?

Posted by Autophil on Server Fault See other posts from Server Fault or by Autophil
Published on 2011-03-19T03:06:54Z Indexed on 2012/09/27 3:39 UTC
Read the original article Hit count: 442

Filed under:
|
|
|

Question: what's the best way to handle sub-projects in eclipse when using git for SCM?

Here's the situation. I have a few git projects with a directory structure layed out more or less like this:


  • simpleproj
    • app
      • www
      • admin
      • demo
    • lib
      • model
      • orm
      • view
    • model
      • user
      • blah

...

  • storeproj
    • app
      • www
      • about
      • mobile
      • fbapp
    • lib
      • model
      • orm
      • view
    • model
      • user
      • message
      • cart
      • product
      • merchant

Each directory in "lib" contains a separate project, either created in-house or forked, all of which use git for source control. So I figured I should make them submodules of my projects, right? Well, we've been moving toward eclipse + egit, because some of our windows guys not used to a CLI need something they can use without being scared of screwing things up. Anyway, the problem is, egit doesn't support submodules. So, my solution has been a rather crude one involving symlinks...

lets say my directory structure on my dev box is generally layed out like this:

  • ~/projects/
    • bigproj
      • .git
      • app
      • lib
        • model (-> ~/lib/model/src/)
        • orm (-> ~/lib/orm/src/)
    • neatproj
      • .git
      • app
      • lib
        • view (-> ~/lib/view/src/)
    • oldproj
      • .git
      • app
      • lib
        • orm (-> ~/lib/orm/src/)
  • ~/lib/
    • model
      • .git
      • src
      • README.md
    • orm
      • .git
      • src
      • COPYING
    • view
      • .git
      • src

...the symlinks link to a subdirectory of the directory containing the git repo, so eclipse doesn't get confused, and everything sort of works. On my machine, I can update the libs from anywhere and all projects will be updated (needing to be committed again of course).

Each project stores a separate copy of the contents of the symlinked directories within "lib" -- but only when staged from within eclipse. After committing from eclipse and moving back to the CLI, git sees that a bunch of files have been removed and a few symlinks have been created. Of course this is acceptable also, probably more so than keeping a separate history of the libs for each project... but eclipse and CLI git obviously need to be on the same page so tons of files aren't vanishing and reappearing.

So this brings me to my question. I'd like to know how to either:

  1. get eclipse+egit to see the symlinks as symlinks if git will somehow handle them properly*, or

  2. get the CLI git to treat them as non-symlinks.

Or, if there's a better way to do this, I'm all ears.

Hope this all made sense! :D

Note: tried to tag this as git-submodules, but was not allowed :(

* should I make them relative or absolute? Either way it's a mess. Also will symlinks will work on windows? i know there's something similar but you need a 3rd party tool to manage them AFAIK, i doubt these would translate well.

© Server Fault or respective owner

Related posts about git

Related posts about symbolic-link