Can sparse-checkout patterns be added to .gitmodules?
Asked Answered
S

0

8

Let's say I have a git submodule and I want to to enable sparse-checkout on it. Is it possible to do so and add that file to the repository for other people that clone? The git submodule gets added to /.gitmodules but the sparse checkout file for that submodule is in .git/modules/foo/info/sparse-checkout? How can I configure a git submodule such that when other people clone with --recursive they only get the whitelisted directories? How can I save the configuration of sparse-checkout on submodules into the repo?

Sigmatism answered 24/2, 2021 at 15:26 Comment(7)
Well, I'm sure you know that the answer is "no way". BTW, if you want to configure sparse checkout for everyone who clones the superproject may be there are simply too much info that shouldn't be in the submodules?Schrader
You already saw this and probably all of that. That the best you can get. You can simplify workflow for the other people by creating a script and recommending them 1st run git clone without --recursive and then run your script in the fresh clone of the superproject to configure and fetch submodules.Schrader
@Schrader of course there is too much info that shouldn't be in the submodules. Agree fully. It's gross. I don't control it though. But valid conclusion...Sigmatism
@Schrader I believe I did, but if you're asking me to conclude that the there is "no way" on the presence of two other questions that don't specifically ask this question, I'd rather put it to the peanut gallery than assume. I'm not exactly the best with the Git.Sigmatism
@Schrader for example, let's say you had a project Foo and it needs to be have a set of patches if you wish to use it with Bar, but those patches are published in a subdirectory in Bar's repo. I want to add that sub directory into my fork of Foo, and leave the rest of Bar behind.Sigmatism
"…a project Foo and it needs to be have a set of patches if you wish to use it with Bar, but those patches are published in a subdirectory in Bar's repo." Seems like Foo must be a submodule of Bar, not the other way around. Or else those patches shouldn't be in Bar repo at all. But if you're out of control please take my sympathy.Schrader
@Schrader that's may be a better idea, and I never thought of it and I'm not sure why. Never entertained it. Seems goofy but it may work. Normally you bring the patches to the project, not the project to the patches. Even more so if the patches come along with hundreds of megs of stuff you probably don't need to build the actual project.Sigmatism

© 2022 - 2024 — McMap. All rights reserved.