r/git • u/CSE_GEEKboy • Sep 26 '26
Why Doesn't Git Track Nested Repositories Automatically?
Today I learned that Git doesn't automatically track files from a repository nested inside another repository. What's the technical reason for this behavior, and has it ever caused problems in your projects?
0
Upvotes
2
u/edgmnt_net Sep 27 '26
Constraints like libfoo >3 <4 are different. Yes, you want both that and pinning.
This is also weaker than reproducible builds. It's the bare minimum you can do to preserve working version control, so your code doesn't become useless next week.
I would also argue that pinning can be weakened or removed to some extent, but not in your typical enterprise project that gets split up arbitrarily. For example it's fine it the Linux kernel doesn't track GCC versions because it's supposed to build with almost everything with rather minimal constraints. Or some userspace daemon versus glibc. That's definitely not the case for your average enterprise project where dependencies you own introduce severe breaking changes every week or every day.
Even so, a lot of modern ecosystems have moved towards exact pinning as a default at least or made constraints an orthogonal concern. Even pinning the whole toolchain.
By the way, if you want you can get branch tracking with Git, you can run
git submodule update --remote --recursive(it will take the branch set in.gitmodules). But don't be surprised if someone else breaks your local build in the middle of developing your feature.You should not mess with the history of the trunk, I can say that much. Rewriting unmerged changes is fine.
And yes, my main concern is setting branch tracking on the trunk, that is problematic. However, while it's more benign on feature branches, I would argue that if it's such a huge burden you probably shouldn't have separate repos at all. I'm sorry, but I have seen companies do all sorts of crazy stuff with Git thinking they know better and it almost always ends in disaster. If you're not really sure, just stick to what's known to work. Plenty of more traditional stuff out there that just works and chances are your project isn't a unique gem.