I have a couple of working trees with some dependences. AFAIK, git submodule would enforce the following:
I don't mind the repos getting bigger, but having the copies is quite unacceptable for me. It would force me to reorganize all the projects, so that the copy would get linked. Moreover, editing of a wrong file could easily happen leading to confusion.
I've got another idea:
The only problems I can see are the following:
I'm asking if somebody already implemented it (or if it's a bad idea).
Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.
A Git subtree is a replica of a Git repository that has been dragged into the main repository. A Git submodule is a reference to a particular commit in a different repository. Git subtrees, which were first introduced in Git 1.7. 11, help you make a copy of any repo into a subdirectory of another.
A git submodule is a record within a host git repository that points to a specific commit in another external repository. Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.
Gitslave is a value added supplement designed to accelerate performing identical git actions over all linked repositories and aside from one new file in the superproject, adjustments to . gitignore, and perhaps a few private config variables, does not otherwise affect your repositories.
I think this is a bad idea because it's strange and it will take you off the supported path for many things.
First a clarification: When using submodules, the 'master' (referencing) repo does not get appreciably bigger. It stores only a repository reference (URL, probably) and a commit ID. But that doesn't seem to be the sticking point here.
When dealing with a problem like this there are three basically 3 paths you can go down:
Put everything in a single repository. Have you convinced yourself 10 times that you really need to separate things out? Remember that you can start in one repo and split things out later. Also remember that git merges actually work, so developer contention isn't that much of an issue.
Use some external package management system. Git is NOT, and doesn't pretend to be, a package manager. Odds are good that the platform you're using has a package manager that supports more complex dependency situations. Maven, rubygems, npm, nuget... there are lots of them.
Use submodules 'mounted' in subdirectories.
Basically, submodules should be your last choice when dealing with your own code. They're great for dealing with third party libraries, but end up being a royal pain for your own code. Add on top of that the complicated solution you're proposing, and it just won't be very fun to work in.
I am not sure I am following you since a parent repo (your "master") only store a reference to the tight SHA1 of a submodule (the sub-repo checked out within the parent repo).
The size of the parent repo isn't affected at all.
The subtree merge strategy (better managed though git subtree) would increase the size of the parent repo, but that (subtree merge) isn't what you are talking about.
The other alternative to submodule would be git-slave (gits), which is a bit like you want to implement.
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