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

posted @ 2021-01-03 17:52  windin  阅读(300)  评论(0编辑  收藏  举报