If you have a huge repository (in size and in history) and want to add a subfolder to your project as a submodule you can follow the code in this example to save time and space using git’s shallow clone and sparse checkout feature. It is a bit more complicated in this example because I assume that you want your submodule to track a non-default branch, called `mybranch`, instead of the `master` branch. Also I assume you already have a checkout of our huge repository somewhere, so it can be used as an argument to the
git clone. Things could probably get a lot simpler when using the default branch and just using a normal clone (with no reference repo). After following the commands in these examples you can use `git submodule update` and `git submodule update –remote` as normal.