Git仅拉取子目录的内容

Git仅拉取子目录的内容

最近在部署博客自动部署的时候有一个仅拉取git仓库子目录的想法,在网上找到了方法,特记下以备忘。

1
2
3
4
5
6
mkdir sample && cd sample
git init
git remote add -f origin https://github.com/pinke/trydone.git
git config core.sparseCheckout true
echo public >> .git/info/sparse-checkout
git pull origin master

参考链接

  1. GITHUB上如果只取出子目录内容怎么办呢? - 百度经验