可以通过以下步骤只下载 Github 仓库中的部分文件夹:
-
进入仓库页面,找到要下载的文件夹。
-
点击文件夹进入,将页面链接复制。
-
打开终端(命令提示符),输入
git clone
命令并粘贴刚才复制的链接。
例如要下载名为 "example" 的文件夹,链接为 "https://github.com/username/repository/tree/master/example",则命令应该为:
git clone https://github.com/username/repository.git --depth 1 --branch master --single-branch example
其中 --depth 1
表示只下载最新的一次提交记录,--branch master
表示下载主分支,--single-branch example
表示只下载名为 "example" 的文件夹。
- 执行命令,等待下载完毕即可。
注意:这种方法只能下载指定文件夹的最新版本,如果该文件夹之前有修改过则无法下载历史版本。如果需要下载历史版本,请使用 Git 版本控制工具。