mkdir sampledir
cd sampledir
git init
git remote add origin giturl
cd .git
vi config
增加sparsecheckout = true 保存退出wqecho "/123/456(想克隆的目录路径)" >> .git/info/sparse-checkout
cd ..
git pull origin master
例如我的.git/config配置
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
sparsecheckout = true // 加上这句话
[remote “origin”]
url = https://github.com/qiniu/java-sdk.git
fetch = +refs/heads/:refs/remotes/origin/