20200512-github获取仓库中指定文件夹

2020-05-12  本文已影响0人  JeremyL

获取仓库中指定文件,而不用下载整个仓库。

"Sparse checkout" allows to sparsely populate working directory. It uses skip-worktree bit (see git-update-index(1)) to tell Git whether a file on working directory is worth looking at.

命令

#初始化
git init
#启用Sparse Checkout
git config core.sparseCheckout true
#在sparse-checkout文件中指定文件目录信息(需要拉取的目录);多个文件,多次写入即可
echo 'github file directory' >> .git/info/sparse-checkout
#查看.git/info/sparse-checkout文件
vi .git/info/sparse-checkout
#添加远程仓库
git remote add -f origin https://github.com/****.git
#拉取
git pull origin master

当前工作目录下只会有下载指定的目录;这种方法对于获取大的项目部分信息是极为方便的。

参考:
Sparse checkout
Git 使用指南

上一篇 下一篇

猜你喜欢

热点阅读