(1) 方法一
mkdir <work_dir> & cd <work_dir>
git init
git config core.sparsecheckout true
echo apps >> .git/info/sparse-checkout
echo os/apps >> .git/info/sparse-checkout
(2) 方法二
# Clone the repo, but don't check it out
# Note the "--filter=blob:none" makes it do a partial clone, which will save you lots of time
git clone --no-checkout --filter=blob:none git@gitlab.dev.com:firmware/os.git
# Go to the repository
cd os
# Configure sparse-checkout in cone mode
git sparse-checkout init --cone
# Add the "apps" directory to your sparse-checkout
git sparse-checkout set apps/
# Now we can do a checkout, and will only get the "apps" directory (in addition to files at the root)
git checkout