1

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
  • recommended reading: Where does my git question go?
    – gnat
    Aug 6, 2014 at 14:09
  • Thanks gnat. That's a good resource. I'd say my question is about workflow and I quote "These are questions for Programmers.SE." Aug 6, 2014 at 14:11

1 Answer 1

1

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 or git 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
  • Thanks for your response. That sounds reasonable to me. In my case, I think I just wanted to keep the second repository in the parent folder because it made sense to do so logistically and the second repository wasn't really part of the source tree so I opted to NOT make it a submodule. It sounds like I did the right thing. I appreciate the background on this. Your answer helped me to see how submodules would be a benefit in a different situation. Sep 3, 2014 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.