赞
踩
git clone --filter=blob:none --sparse 克隆的仓库 --no-checkout
cd 仓库名称(进入刚刚克隆的文件夹)
git sparse-checkout init --cone
然后进入.git/info/sparse-checkout文件,用记事本打开,输入要克隆的文件夹或文件,例如
然后再在终端输入以下命令,开始下载
git checkout
后续要添加克隆文件或文件夹,再次进入该文件添加,再执行git checkout即可
参考:https://blog.csdn.net/weixin_45759139/article/details/133377508
补坑,几天后后续操作不当导致报错,并且部分文件消失,此时修改.git/info/sparse-checkout文件为想要的文件夹,重现检出
warning: The following paths are not up to date and were left despite sparse patterns:
After fixing the above paths, you may want to run `git sparse-checkout reapply`.
Your branch is up to date with 'origin/main'.
执行
git config core.sparseCheckout false
git config core.sparseCheckout true
echo "path/to/directory/" >> .git/info/sparse-checkout
git checkout
参考:文心一言
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。