How do I add subrepos that are not tracked by the parent

Hi Guys, 

I created a directory called website and initilised it as a git repo.  I then created a .gitignore file and added /bin/ and /src/ to the .gitignore and commited the changes to git.  After that I created three subdirectories within the parent directory.  assets, bin, src.

So my directory looked like this:


After this, I created several directories within the assets and src subdirectories, so I ended up with this directory structure.


At this point I conected the local git repo to the remote that I had created on github and created an initial-setup branch from the master.

The purpose of this structure is to give me a dump directy and a directory from which I can run sass and because both /bin/ (my dump directory, where everything will be dumpped before it is worked on) and the /src/ (my sass working directory; have been added to the .gitignore, git is not tracking them and they wont be pushed to the remote when the root directory is pushed.

However, I would like the /bin/ and /src/ directories to still be git repos and have corrisponding remotes on github.  I would like this so that all my dump files and sass files are backed up, use version control and are easy for me (and other memebers of the team if my project expands) to aquire all the current working material by cloning the /bin/ and /src/ private repos from github.

The working material should not be part of the repo that houses the production material though.  Thus is the purpose of keeping /bin/ and /src/ from being tracked from within the root directory.

Is it at all possible to have subdirectories within a git repo that are not tracked by git from within the parent directory; so that they are not pushed to the parents remote, but which themselves are git repos and seperately tracked by git and pushed to their own individual remotes?

Yeah you can just add the following lines:


to the .gitignore file of your git repo in your “Website” directory, then initialize seperate Git repositories in the /bin/ and /src/ directories.

Or do you want to do something else?

1 Like

Hi @mpboom

That is exactly what I wanted.  Thanks.  I had thought it would be much harder than this actually.   I will alter my .gitignore to include the asterisk after the / and go ahead and do this now.

Thanks for your reply


Hi @jaytelford, I read your message, and I mostly comprehend your question. That message would be easier comprehend if it would be more accurate. An edited version would be really useful because I think your question is really appropriate. To answer your question, you should use some Git submodules. A submodule essentially is a subrepo. Those two are synonymous, but “subrepo” probably cannot be found in Git documentation. You can utilize submodules in your repository, and ignore some directories in your repository to accomplish what you plan to do.

@mpboom, to use a Git repository in another Git repository would be quickly doable if the coder, @jaytelford in this case, does not know much about a Git submodule.