Update Sep. 2016: there are a few tools created by the community that can do this for you:
(2016年9月更新:社区创建了一些工具可以为您做到这一点:)
Git doesn't support this, but Github does via SVN.
(Git不支持此功能,但是Github通过SVN支持。)
If you checkout your code with subversion, Github will essentially convert the repo from git to subversion on the backend, then serve up the requested directory. (如果您使用subversion签出代码,Github实际上将在后端将仓库从git转换为subversion,然后提供所请求的目录。)
Here's how you can use this feature to download a specific folder.
(这是使用此功能下载特定文件夹的方法。)
I'll use the popular javascript library lodash
as an example. (我将以流行的javascript库lodash
为例。)
Navigate to the folder you want to download .
(导航到要下载的文件夹 。)
Let's download /test
from master
branch. (让我们从master
分支下载/test
。)
Modify the URL for subversion .
(修改用于Subversion的URL 。)
Replace tree/master
with trunk
. (将tree/master
替换为trunk
。)
https://github.com/lodash/lodash/tree/master/test
?
(https://github.com/lodash/lodash/tree/master/test
)
https://github.com/lodash/lodash/trunk/test
Download the folder .
(下载文件夹 。)
Go to the command line and grab the folder with SVN. (转到命令行并使用SVN抓取文件夹。)
svn checkout https://github.com/lodash/lodash/trunk/test
You might not see any activity immediately because Github takes up to 30 seconds to convert larger repositories, so be patient.
(您可能不会立即看到任何活动,因为Github最多需要30秒来转换较大的存储库,因此请耐心等待。)
Full URL format explanation:
(完整的URL格式说明:)
- If you're interested in
master
branch, use trunk
instead. (如果您对master
分支感兴趣,请改用trunk
。)
So the full path is trunk/foldername
(所以完整路径是trunk/foldername
)
- If you're interested in
foo
branch, use branches/foo
instead. (如果您对foo
分支感兴趣,请改用branches/foo
。)
The full path looks like branches/foo/foldername
(完整路径看起来像branches/foo/foldername
)
- Protip: You can use
svn ls
to see available tags and branches before downloading if you wish (提示:如果愿意,可以在下载前使用svn ls
查看可用的标签和分支)
That's all!
(就这样!)
Github supports more subversion features as well, including support for committing and pushing changes. (Github还支持更多的Subversion功能 ,包括对提交和推送更改的支持。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…