Git 克隆部分文件
- 使用
sparse-checkout(推荐)
git clone \
-b master \
--depth=1 \
--filter=blob:none \
--sparse \
<repo-url> \
<repo-name>
cd <repo-name>
git sparse-checkout set <file-path>
<repo-url>为仓库地址;<repo-name>为项目名称;<file-path>为需要克隆的文件。
使用 git sparse-checkout list 可查看检出的文件。
- 使用
--no-checkout标签
git clone \
-b master \
--depth=1 \
--filter=blob:none \
--no-checkout \
<repo-url> \
<repo-name>
cd <repo-name>
git checkout master -- <file-path>
此方法会逐个拉取文件,若文件数量多拉取会非常耗时。仅需克隆少量文件时可使用。
参考:
浙公网安备 33010602011771号