Working with Git Sparse-Checkout

Goal: Checkout and work with only a subset of folders from a repository.

Initial Setup

git clone URL --no-checkout # add `--depth 1` to only include latest commit
cd REPO_ROOT
git sparse-checkout init --cone # `--cone` includes root files
git checkout

Add Folders to Checkout

git sparse-checkout add Apps/OtherApp
git sparse-checkout list # view currently checked out paths

Create New Folder and Add to Checkout

cd ROOT/Apps
mkdir OneMoreApp
git sparse-checkout add Apps/OneMoreApp
git sparse-checkout list

Standard Git Operations

Work from any included folder:

cd App/OneMoreApp
git add .
git commit -m "cool descriptive message"
git push origin master

Update Repository

Pull from any checked out folder:

cd App/AnyApp
git pull

Only files in your sparse-checkout paths will be downloaded.

Note: Branching behavior with git branch is untested with sparse-checkout.

Disable Sparse-Checkout

cd ROOT
git sparse-checkout disable