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?

4 answers

1 accepted

1 vote
Accepted answer

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

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

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.

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!

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?

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:

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.

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

Hopefully that makes sense.

Cheers

awesome thanks

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

841 views 3 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you