I have a git repository with a folder in it. The folder is listed in my .gitignore file. I cloned another repository into that ignored folder from github. I may want to work inside of the new repository but I don’t see any reason for it to be a part of the original repository. Perhaps I should just keep it outside of the original repository but it seems (to me anyway) like a reasonable place for it thematically (its in a place where I would know to look for it).
I guess I’m having a hard time getting my head around the concept of a submodule. My specific question is “Should I use a submodule in this situation, even when the folder is ignored?”
I noticed that “git status” gives me status of my original repository even though I issue the command inside of the ignored folder
2
It really depends on the relationship between the original repository and this new repository. Is one a dependency of the other?
Quoting from the git-submodule documentation:
[…] submodules are meant for different projects you would like to make
part of your source tree, while the history of the two projects still
stays completely independent […]
If the new repository is something that your original repository depends on, and you would like to keep it in a specific place in your source tree, it would make sense to make it a submodule. That would give you the ability to:
- Automatically clone and check out the submodule repository in the right place, after cloning the main repository
- Pin the submodule repository to a specific commit
- Work on (and see the status of) the submodule repository more easily, with
git submodule status
orgit submodule summary
However, since you say:
I don’t see any reason for it to be a part of the original repository.
it sounds like the repositories have no relation and submodules might not benefit you. If this is the case, it would probably be simplest to keep the repositories separate.
1