submodules
Asked by Ed Pataky:

i have a repo setup with a directory structure like this:

FOLDER1/

/.git/

/fldrA/

/fldrB/

How can I setup one of the subfolders as a submodule, so one of the users can check out only that section?


Answers:
author: Johannes Kilian
body: You've got a wrong understanding of submodules:

Mainly a submodule is a standalone git-repository, which can be used as a submodule within any other module.

In your case, you have to isolate the desired folder to a standalone git-repository and your main project ("Folder1") has to use this standalone repository as submodule.

Splitting a subdirectory into an own repository is described for example [here](http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository)

comments: author: epataky
body: You say I do not understand but you explain exactly what I said ... at least to me .. my feeling about most software is I dont care much why it works, i only care how to use it ... so your answer sounds perfect to me .. all i want is to be able to pull from the top level, and have other people pull from an inner folder .. it sounds like this is possible .. thank you


author: Johannes Kilian
body: I'm not quite sure, I've got you correctly.

You say: "all i want is to be able to pull from the top level, and have other people pull from an inner folder"

I say: it's not possible to do this in a direct way - the desired "inner folder" has to be a repository on it's own. You have to incorporate this repository within your top level repository as submodule - and other people can use this repository directly.

I assumed you already have a git-repository with the structure described in your initial question. Starting from this point an inner folder of your project cannot be used as separate repository by other users. What I described is a way to split your inner folder from project to a standaone repository and incorporate it as a submodule in your project repository.


author: epataky
body: Johannes, yes thank you .. what you are saying is perfect .. all i have to do is make my "inner folder" a repository, then i can include it as you say .. i will have access to the top level, and i will make the inner folders a submodule .. noone will know the top level url so i can keep some things hidden ... again, i am an engineer, so i don't know or care what you want to call it, or if it is ideal or not, i am only interested in a practical solution, it sounds like you have given one .. unless i am missing something ... thank you i will try .. i think it sounds perfect


author: epataky
body: awesome thanks


author: KieranA
body: Adding to Johannes answer I'd also suggest reading the "Submodule" chapter in the Git book here: <http://git-scm.com/book/en/Git-Tools-Submodules>

This will help you understand submodules even further, but Johannes is correct about them in the short term.

Good luck!

comments: author: epataky
body: i have read that section, the problem is all the git documentation is all text based, and I am not interested in doing anything via text commands .. this is why i use SourceTree and why I posted the question here, and not in the git google group .. i want to know how to do it from SourceTree .. the documentation explains things ok, but it does not help me with SourceTree .. too bad there is no SourceTree documentation ... if there is, where is it?


author: KieranA
body: If what you're trying to do is add a submodule you can simply context-click in the sidebar and hit "Add submodule" as follows:

![](http://i.imgur.com/cIpYPWp.png)

Following this you'll see the add submodule sheet where you enter the URL for the submodule repository and you can enter a relative path to your local repository. In your case you'd specify "fldrA" as the relative path.

![](http://i.imgur.com/Pauw6Hn.png)

The source path allows you to choose a repository from your hosted repositories too.

Hopefully that makes sense.

Cheers