DEV Community

GhostBasenji
GhostBasenji

Posted on

How to work with git submodule?

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:
onetheme_repo:
repo_001
repo_002
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.

Top comments (6)

Collapse
 
jingxue profile image
Jing Xue

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.

Collapse
 
ghostbasenji profile image
GhostBasenji

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

Collapse
 
jingxue profile image
Jing Xue

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.

Thread Thread
 
ghostbasenji profile image
GhostBasenji

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

Thread Thread
 
jingxue profile image
Jing Xue

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.

Thread Thread
 
ghostbasenji profile image
GhostBasenji

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