方法一:SVN-下载单个文件夹
个人最适应的方法,缺点是需要借助第三方工具-svn
环境:Windows 10
若想要下载{username}的{repo}里的{dir}文件夹,
主分支master(现在似乎默认是main了,区别不大):
其浏览器路径应为
https://github.com/{username}/{repo}/tree/master/{dir}修改
/tree/master/为/trunk/打开
cmd,输入指令:svn checkout https://github.com/{username}/{repo}/trunk/{dir}该
{dir}将被下载至当前目录下
特定分支
- 将
/trunk/换成/branches/{branch_name}即可
- 将
方法二:高版本 Git
这个方法较为繁琐,但无需像前者一样借助其它工具
方法:Git 的Sparse Checkout模式,指定文件/文件夹
创建空的本地仓库,并将远程
Git Server URL加入到Git Config里mkdir project_folder cd project_folder git init git remote add -f origin <repo-url>在
Config中设置允许使用Sparse Checkout模式git config core.sparsecheckout true在
.git/info/目录下新建sparse-checkout文件(注意文件名不要错了),写入需要的文件(一行为一项)如:
/source/tools/index.html /source/about以正常方式从服务器pull下来即可
git pull origin master