How to work with git submodule?

ghostbasenji profile image GhostBasenji ・1 min read

I have several repository projects. And in order not to create a bunch of repositories, I decided to combine them into one repository, because they are on the same topic.
Here is the repository structure:
and so on.
As I understand it, git uses the submodule command for this.
A question -- when creating a new project and saving it to the repository, do I need to use the submodule command every time?
P.S. Sorry for my bad English. I'm hard of hearing, and I'm learning to work with git.


markdown guide

I'm afraid submodule isn't going to help you avoid creating multiple repositories. It lets you "mount" a subproject from another repo into your main project, which means the subproject still needs to have its own repo to become a submodule.


Thanks. How do I do this, and what command should I use?


I can't think of a git way that does what you want. If you don't want to create multiple repos, and instead want to keep all the projects in one repo, just keep them under the same root directory, and, well, commit them to the same repo.

In every project, still need to file .gitignore?
Or is one file per repository with multiple projects sufficient?

It really depends on how different your projects are going to be from each other. You can have a .gitignore in each project so that it can be customized specifically for the project. You can also have one .gitignore at the repo root which would be simpler to maintain.

Yes, the programming language will be the same for all repositories.
Thank you very much.