如何从GitHub上托管的远程Git repo中仅下载特定文件夹或目录?
举个GitHub repo的例子:
git@github.com:foobar/Test.git
其目录结构:
Test/
├── foo/
│ ├── a.py
│ └── b.py
└── bar/
├── c.py
└── d.py
我只想下载foo文件夹,而不是克隆整个测试项目。
如何从GitHub上托管的远程Git repo中仅下载特定文件夹或目录?
举个GitHub repo的例子:
git@github.com:foobar/Test.git
其目录结构:
Test/
├── foo/
│ ├── a.py
│ └── b.py
└── bar/
├── c.py
└── d.py
我只想下载foo文件夹,而不是克隆整个测试项目。
当前回答
可以按以下方式使用git-svn。
首先,用主干替换树/主节点然后,通过sudoaptinstallgitsvn安装gitsvn
git svn clone https://github.com/lodash/lodash/trunk/test
这样,您就不必经历设置svn的痛苦,特别是针对Windows用户。
其他回答
另一个具体示例:
就像我想从url下载“iOS Pro Geo”文件夹
https://github.com/alokc83/APRESS-Books-Source-Code-/tree/master/%20Pro%20iOS%20Geo
我可以通过
svn checkout https://github.com/alokc83/APRESS-Books-Source-Code-/trunk/%20Pro%20iOS%20Geo
注意路径中的主干
编辑:(根据Tommie C的评论)
是的,使用导出而不是签出将提供一个干净的副本,而无需额外的git存储库文件。
svn export https://github.com/alokc83/APRESS-Books-Source-Code-/trunk/%20Pro%20iOS%20Geo
已编辑:如果树/主节点不在url中,则分叉它,它将在分叉的url中。
我创建了一个简单的应用程序,支持下载目录、文件和存储库(私有/公共)。
应用程序:https://downdir.vercel.app/
github:https://github.com/renomureza/downdir
要从GitHub导出目录,请将目录url中的“/tree/master/”替换为“trunk/”。
例如,要从以下URL导出目录:
https://github.com/liferay/liferay-plugins/tree/master/portlets/sample-hibernate-portlet
运行以下命令:
svn export https://github.com/liferay/liferay-plugins/trunk/portlets/sample-hibernate-portlet
你可以尝试为chrome使用gitzip扩展,它超级容易使用,而且以前也帮我下载了很多文件夹!
一个简单的答案是从下面的链接中选择第一个乌龟svn。
https://tortoisesvn.net/downloads.html
安装时打开CLI选项,以便可以从命令行界面使用它。
复制github子目录链接。
实例https://github.com/tensorflow/models/tree/master/research/deeplab
用树干替换树/主
https://github.com/tensorflow/models/trunk/research/deeplab
并且做到了
svn检出https://github.com/tensorflow/models/trunk/research/deeplab
文件将被下载到当前目录中的deeplab文件夹中。