5

I'm trying to make a private mono-repo, with sub packages that have public gits. At no point do I have any intent of modifying the code outside of my mono-repo, so I have no need for submodules. In fact, they're the very thing I'm trying to avoid at all costs.

I don't want to delete the .gits for any of the packages in my mono-repo, and I don't want to do anything fancy.

How can I simply disable submodule functionality in git?

I don't ever want anything to be considered a submodule. Never have, and probably never will.

I've tried searching for some .submodule folder or something in the git. I found none. There appears to be no settings to get rid of these things.

I've found this link: un-submodule a git submodule

Unfortunately, these solutions all have to do with flattening submodules, and none of them cover a way to just disable the feature entirely.

Seph Reed
  • 8,797
  • 11
  • 60
  • 125
  • What is your goal with the subprojects: you want to be able to make changes to them and, what, commit the changes to your mono-repo instead of the public repos? When you are inside them do you want to see the subprojects' histories or mono-repo history? – John Kugelman Jul 17 '19 at 23:32
  • I'm not clear on why you want to avoid submodules. – John Kugelman Jul 17 '19 at 23:33
  • My goal is that if my git project finds a sub folder with a `.git` in it, it does not care, and does nothing about it. I want to be able to do this because the parent git is the version controller for the child git. At no point will the child git be pulled, and it will only be pushed for sharing releases. Whether or not this is something you yourself would do is not the question though. Can it be done is the question. – Seph Reed Jul 17 '19 at 23:37
  • Can _what_ be done, not adding submodules? You don't need Git's help for that. Just don't add them. Done. – jthill Jul 17 '19 at 23:44
  • You should ask a more specific question if you can't understand what I'm trying to achieve. I've done my best to explain it. Imagine if git didn't have such thing as submodules. What would it do if a sub folder had a `.git`? That's what I want. – Seph Reed Jul 17 '19 at 23:45
  • Then that should have been your question. [Disable detection of a specific submodule by adding anything in it first](https://stackoverflow.com/questions/22685170/ignore-git-folder-in-sub-folder/49203257). Once per submodule you want to bypass is all you need. – jthill Jul 17 '19 at 23:54

1 Answers1

2

Git doesn't have a feature to disable submodules. They're considered part of the core functionality and Git doesn't have options to disable core functionality like that. It's extremely unlikely that such a feature would be added.

If you don't want your subrepos to be accidentally be checked in as submodules, you can ignore them, in which case Git won't check them in. If they're already checked in, you can just run git rm --cached DIRECTORY for each submodule and then remove the .gitmodules file, then add them to .gitignore.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • This seems like it would ignore all changes to the folder which is being treated as a submodule. – Seph Reed Jul 17 '19 at 23:41
  • It will ignore all changes to it in the parent repo, yes. The child repo will be independent and won't be affected by the parent ignoring it. – bk2204 Jul 17 '19 at 23:43
  • This would not be disabling submodules at all. This would be ignoring anything that git would treat as one. – Seph Reed Jul 17 '19 at 23:43
  • Yes see bk2204's entry statement - "GIt doesn't have a feature to disable submodules". I like this response, and use it now – J-Dizzle Apr 18 '20 at 15:32