git克隆库中部分文件
创建空仓库:
git init [repo]
添加远程库地址:
git remote add origin [url]
设置分散检出配置项为真:
git config core.sparsecheckout true
输入要克隆的部分文件路径地址(相对于根路径)到文件:
echo "path/" >> .git/info/sparse-checkout
开始拉取文件:
git pull origin master
拉取完成后可以测试切换到主枝:
git checkout master
例如:要下载FlatBuffers中的.NET部分代码到本地:
库地址:https://github.com/google/flatbuffers
.NET部分代码路径:.../flatbuffers/net/FlatBuffers
执行过程:
$ git init
>Initialized empty Git repository in flatbuffers.net.code/.git/
$ git remote add origin git@github.com:google/flatbuffers.git
$ git config core.sparsecheckout true
$ echo "net/FlatBuffers" >> .git/info/sparse-checkout
$ git pull origin master
>Resolving deltas: 100% (12581/12581), done.
>From github.com:google/flatbuffers

浙公网安备 33010602011771号