Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Pilot Lvl 1
Message 1 of 2

Can I create one projects repo and pull in all other projects/project files as submodules

Hi, 

 

I was wondering if anyone could tell me whether or not this would be possible using the git/GitHub workflow.  I want to create local git repo called projects - this local projects repo will have a corresponding remote and will house all my projects (each housed in its own repo) as submodules.

 

So my list of repos would look something like this:

 

dreamweaver/ - [public repo]
  website-1
    index.html
assets/
images/
image-1.png
image-2.png
css/
main.css         js/         jquery/         pdf/
blog/
blogfile-1.html
contactus.html

-------------------------------- premier-pro - [private repo]   project-1/        imported/           file-1           file-2           file-3           file-4        exported/           file-1           file-2           file-3           file-4   project-2/        imported/           file-1           file-2           file-3           file-4        exported/           file-1           file-2           file-3           file-4

--------------------------------

 

Then my projects repo would pull in all my other repos as submodules and would look something like this

 

projects - [private repo]

--------------------------------

    dreamweaver - [submodule] - [public as per repo settings]
        website-1
            index.html
            assets/
                images/
                    image-1.png
                    image-2.png
            css/
                main.css
            js/
            jquery/
            pdf/
            blog/
                blogfile-1.html
            contactus.html

--------------------------------

    premier-pro - [submodule] -  [private as per repo setting]
        project-1/
            imported/
                file-1
                file-2
                file-3
                file-4
            exported/
                file-1
                file-2
                file-3
                file-4
        project-2/
            imported/
                file-1
                file-2
                file-3
                file-4
            exported/
                file-1
                file-2
                file-3
                file-4

--------------------------------

 

Thus I would have one directory on my local machine [git/GitHub repo] that housed multiple directories [submodules] for each repo that represents its related project.  Allowing me to not only maintain version control for all files within individual projects but also for all projects as a whole.

 

This would give me a form of backup and make it easy to maintain all projects across multiple loacations. 

 

By simply cloning my projects repo and pulling in all submodules - I could instantly get access to all the latest files within every project on any machine I am working on.  The same for backups - if I needed to I could clone the projects repo and pull in all submodules to not only get back all files from all projects but all versions of said files as well.

 

This is getting kind of long but I think you will get the idea of what I am wanting to do.

 

My question is though - is it possible to use git/GitHub in this way?

 

Cheers

Jay

 

1 Reply
Pilot Lvl 2
Message 2 of 2

Re: Can I create one projects repo and pull in all other projects/project files as submodules

Hello @jaytelford,

 

Yes, you can do this with Git and GitHub — more info on this is available at https://blog.github.com/2016-02-01-working-with-submodules/ however there are a couple of points you need to be aware of when using submodules:

 

  • Git won't download your submodule content by default. You'll need to run commands like git submodule update and git clone --recursive to ensure you download the submodule content
  • Collaborators also won't automatically see any updates to submodules — they'll need to run git submodule update too otherwise they'll see odd behaviour.
  • Managing rapidly-evolving or dynamic submodules can become frustrating quite quickly.

 

​If there's anything else I can help you with, let me know; so happy to help further!

 

Kindest regards,
Matthew