To checkout and work only with a subset/subtree of folders from a repo (yes, some people insist in economizing repos)
Initialize sparse-checkout config
git clone URL --no-checkout # add `--depth 1` to only include latest commit from all commit history cd REPO_ROOT git sparse-checkout init --cone # `--cone` to include root files git checkout
Set existing folders to be actually checked out
git sparse-checkout add Apps/OtherApp # to add new folders to the current checkout list. git sparse-checkout list # to get the set folders. can be run from any folder in the tree with same results
To create a new app (folder) in the repo and work with it, typical flow would be:
cd ROOT/Apps mkdir OneMoreApp git sparse-checkout add Apps/OneMoreApp git sparse-checkout list # to confirm all the paths included
To operate the repo, just
cd into the desired App folder and
git commands go as expected.
cd App/OneMoreApp git add . git commit -m "-cool descriptive message" git push origin master
When the repo goes outdated, just
cd into one of the folders and
cd App/AnyApp git pull
The repo will update without downloading any unwanted file.
I haven’t tested how branching
git branch works with sparse-checkout, though!. So watch out for this.
Get rid of sparse-checkout
cd ROOT # not sure whether it's required, though.. git sparse-checkout disable