Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git submodule without its own folder

Tags:

git

I want to make some parts of my projects, like my jQuery plugins external. I was looking into submodules for this purpose. They seem quite perfect, because they can be managed and updated in one centralized point. My Only problem is, that they clone into a folder. This leaves me with a structure like this.

/js
   /plugin_one
      plugin_one.js
   /plugin_two
      plugin_two.js

What I want is more like this.

/js
   plugin_one.js
   plugin_two.js

Is that achievable with submodules or am I using the wrong tool?

Cheers.

like image 873
Lukas Oppermann Avatar asked Aug 25 '12 14:08

Lukas Oppermann


1 Answers

Submodules are great for linking together several repo into a fixed set of configuration (ie a collection of SHA1 representing a fixed set of each of those submodules, as recorded by their parent repo)

However, they are always cloned in their own directory.
And they have a lot of other gocha's too (see "Why your company shouldn’t use Git submodules").

One way to go around that is to maintain 2 different sets of working tree:

One not versioned, with all the files together. One with the repos cloned normally (ie with the submodules in their own directory).

You could do in it all the normal operation but with:

  • --git-tree option for each git commands, --git-tree pointing to the first set (the one with all the file in it)
  • a complete enough .gitignore able to ignore any file which isn't part of their particular repo.

That is not very satisfactory, and point out that submodules (even in other VCS which offer them -- Hg and subrepos, ClearCase and UCM component, ...) are supposed to be kept separate.

So sharing a JQuery plugin might first involve a bit of re-thinking the file organization to see if those files can indeed be considered as a "submodule".

like image 72
VonC Avatar answered Oct 03 '22 10:10

VonC