Download a single folder or directory from a GitHu

2019-01-01 11:16发布

How can I download only a specific folder or directory from a remote Git repo hosted on GitHub?

Say the example GitHub repo lives here:

git@github.com:foobar/Test.git

Its directory structure:

Test/
    foo/ 
       a.py
       b.py
    bar/
       c.py
       d.py

I want to download only the foo folder and not clone the whole Test project.

标签: git github
26条回答
看淡一切
2楼-- · 2019-01-01 12:17

1.Click on this link http://kinolien.github.io/gitzip/
2.Paste link of Github folder you want to download.
3.Click on search it will shows all files for downloading.
Note:-Using search there is no need to enter token key ;)..keep it simple(y)

查看更多
其实,你不懂
3楼-- · 2019-01-01 12:19

Whoever is working on specific folder he needs to clone that particular folder itself , todo so please follow below steps ** --- by using SPARSE CHECKOUT --- **

Step 1: Create a directory.

Step 2: Initialize a Git repository. (git init)

Step 3: Enable Sparse Checkouts. (git config core.sparsecheckout true)

Step 4: Tell Git which directories you want (echo 2015/brand/May( refer to folder you want to work on) >> .git/info/sparse-checkout)

Step 5: Add the remote (git remote add -f origin https://jafartke.com/mkt-imdev/DVM.git)

Final Step 6: Fetch the files (git pull origin master )

查看更多
初与友歌
4楼-- · 2019-01-01 12:20

Go to DownGit > Enter Your URL > Download!

Now, you can DIRECTLY DOWNLOAD or create DOWNLOAD LINK for any GitHub public directory or file (specially large file) from DownGit! Here is a simple demonstration-


DownGit


You may also configure the downloaded file's property- detailed usage.

查看更多
倾城一夜雪
5楼-- · 2019-01-01 12:21

There's a Python3 pip package called githubdl that can do this*:

export GIT_TOKEN=1234567890123456789012345678901234567890123
pip install githubdl
githubdl -u http://github.com/foobar/test -d foo

The project page is here

* Disclaimer: I wrote this package.

查看更多
泪湿衣
6楼-- · 2019-01-01 12:22

I've created an open source project, called GitHubFolderDownloader. It lets you to download a single folder of a repository without cloning or downloading the whole repository.

查看更多
倾城一夜雪
7楼-- · 2019-01-01 12:22

You can do a simple download of the directory tree:

git archive --remote git@github.com:foobar/Test.git HEAD:foo | tar xf -

But if you mean to check it out, and be able to do commits and push them back, no you can't do that.

查看更多
登录 后发表回答