Hacker News new | ask | show | jobs
by alexhayes 2962 days ago
I'm unsure why most folks seem to get into a pickle over git submodules but I think it's essentially due to the mental model of how they think about the structure of the "root" project and it's relation to the submodules. This in turn seems to govern how they work with the root project and it's submodules.

I kind of think of the relationship as a pointer into what should be a entirely separately managed project. Changes to that project should happen in that project and only then should the "pointer" be modified. I usually go as far as checking out the submodule separately (to my "projects" directory) when I need to work on it, which of course entirely unnecessary, but for me helps keep that separation.

Another approach I've found that helps to combat issues some people have with them is to not have them littered throughout a project but have a very clear delineation between what are submodule and "root" project git managed files - ie. an appropriately named, usually top level, directory.

In practice I find them an extremely useful way of getting stuff done effectively and efficiently!

2 comments

I agree. I use them extensively with Yocto and the different layers (submodules) that make up my operating system. People have an adversion to them, but I find them easy to work with and very useful.
Effective? Yes. Intuitive? Not so much so.

Your hacks are certainly worth exploring. But they are also solutions to why other people get pickled. Good for you. Not so for them.

I'd be curious to know if you use the CL or a UI-based git tool? It would seem to me - once you get to the necessity / complexity of something that entails submodules - seeing would be believing. Trying to juggle a detailed picture in your head, __and write good code__, __and get your git commands right__ is not exactly a recipe for success.

In many ways git is a great tool. But in the ways it is not expose its Achilles heel as we edge up on the second decade of the 21st century.

p.s. thx for sharing. I'm going to see about using your approaches.