submodules

Ed Pataky
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 17, 2013

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
Answer accepted
Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2013

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

epataky
Contributor
July 17, 2013

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

Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

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.

0 votes
epataky
Contributor
July 18, 2013

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

0 votes
epataky
Contributor
July 17, 2013

awesome thanks

0 votes
KieranA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2013

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!

epataky
Contributor
July 17, 2013

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?

KieranA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2013

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events