▲ | nrclark 3 days ago | ||||||||||||||||||||||||||||||||||
I feel like submodules are one of Git's most misused features. They're intended as a method of pinning read-only upstream Git dependencies. And when used for that purpose, they're good at what they do. I think that people mostly get a bad taste in their mouths because they try to use submodules for building multi-repo workspaces where a developer might need to commit in some/all of the repos. They're a bad fit for that problem, but it's mostly because that's not what they were designed to do. I'd love to see the jj team tackle case #2, personally. I bet they'd do a pretty good job of it. | |||||||||||||||||||||||||||||||||||
▲ | IshKebab 3 days ago | parent | next [-] | ||||||||||||||||||||||||||||||||||
> They're intended as a method of pinning read-only upstream Git dependencies. And when used for that purpose, they're good at what they do. No they are not. In theory they could be good, but the actual implementation falls down in ... let me count the ways: 1. Transitive dependencies. I sure do love that my company's submodule-based repo has 12 copies of one of our dependencies. 2. Checkouts don't work any more. You can't simply `git switch <branch>`, especially if that other branch has a different set of submodules. And good fucking luck if one branch has a submodule and another branch has a not-submodule in the same location. 3. They don't work with worktrees. In theory... maybe. In practice, the documentation says not to try and in my experience it is right! 4. The submodule URLs are now baked into the git repo. This means you can't mirror the repo anymore easily. I've even had cases where I couldn't even clone the repo because the authors had used `ssh://` URLs which required permissions I didn't have. It's insane that the authentication method gets baked into the repo. I have no idea why they implemented it like this. 5. The tooling experience is just way worse. Want to see a diff of everything you've changed? Well you can't. If you've changed anything in a submodule you just get a hash difference, or at best a list of commits (which is better but it's not even the default!). Before you instinctively reach for the "well obviously it must work like that" part of your brain, take a moment to think if it should work like this. I can think of several ways to do it better (beyond just making the implementation less buggy). | |||||||||||||||||||||||||||||||||||
▲ | JoshTriplett 3 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
> They're intended as a method of pinning read-only upstream Git dependencies. Except, dependencies are rarely read-only. | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
▲ | hju22_-3 3 days ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||
Do you know of something that's good for what people tend to misuse Git submodules for? A multi-repo workspace thingamajig. | |||||||||||||||||||||||||||||||||||
|