git - 如何clone仓库的一个文件

浏览:35日期:2023-09-06

问题描述

有个project ,newstart.它里面的文件如下test1test2LICENSE README.md

git clone https://github.com/someone/ne... /tmp/newstart会拉取全部的四个文件。test1test2LICENSE README.md

现在我想仅仅获得test1这个文件夹和它里面的全部东西,请问,有无办法做到?

问题解答

回答1:

需要git1.7以上

$ mkdir test$ cd test$ git init$ git remote add -f origin https://github.com/Rozbo/puck.git$ git config core.sparsecheckout true #开启Sparse Checkout模式$ echo 'app' >> .git/info/sparse-checkout #设置仅拉取app这个文件夹$ git pull origin master

相关文章: