Background:
A small team and I are putting together a project in Main-Repo
. We want Main-Repo
to be opensource eventually. However, Main-Repo
needs to use assets that we don’t want to be opensource. We are currently keeping those assets in Assets-Repo
. All of the collaborators on Main-Repo
have access to Assets-Repo
Problem
We don’t know the best way to embed the Assets-Repo
within the file structure of Main-Repo
. We anticipate that the file structure of Main-Repo
will look something like this:
Main-Repo
|_.gitignore
|_ main.file
|_...
|_Assets-Repo
|_privateImage.png
|_privateAudio.mp3
|_...
Git Clone + .gitignore
This was our initial idea–we clone Assets-Repo
into Main-Repo
locally and add the Assets-Repo
folder to our .gitignore
to keep it out of Main-Repo
‘s source control.
This would mean that we’d have to periodically cd into Assets-Repo
to make or pull changes`, but doesn’t seem like too much overhead. In addition, it should keep all of our information separate and private.
However, when I went to commit the change that cloned Asset-Repo
into Main-Repo
, I got this warning:
You've added another git repository inside your current repository. Clones of the outer repository will not contain the contents of the embedded repository and will not know how to obtain it.
If you meant to add a submodule, use:
git submodule add <url> Assets-Repo
If you added this path by mistake, you can remove it from the
index with:
git rm --cached Assets-Repo
See "git help submodule" for more information.
Submodule Solution
My understanding is that submodules are made with third-party modules in mind. In addition, our Main-Repo
would not be able to function without having access to Assets-Repo
. I read that while it can be used to keep private repos separate while letting users clone the parent repo, it adds a ton of overhead. Is there a meaningful difference between submoduling a private repo vs .gitignoring
it from the parent repo?
Subtree Solution
My understanding is that if Assets-Repo
was a subtree of Main-Repo
, it will get a snapshot of Assets-Repo
. I’ve seen mention that it’s hard to keep the subtree up-to-date, which won’t work, as we’ll be adding to Assets-Repo
as we work in Main-Repo
.
Question
For a private repo within a public repo, both of which are controlled by the same collaborators, what are the pros and cons of embedding the private repo via clone + .gitignore, submodule, and subtree? What is the flow for contributing to either repo?