- How to download a folder from github?
- 11 Answers 11
- Command line:
- How to download a specific folder from a GitHub repo
- How to Download a single folder, directory or partial repo from a GitHub repo
- How to download a single folder of a github repository
- Download with Git
- Solution
- 1) If you are a windows user
- Скачать отдельные файлы из GitHub
- 26 ответов:
How to download a folder from github?
I wished to download the mysite folder from this link: https://github.com/username/repository/master/
11 Answers 11
There is a button Download ZIP . If you want to do a sparse checkout there are many solutions on the site. For example here.
You can download a file/folder from github
Simply use: svn export /trunk/
Ex: svn export https://github.com/lodash/lodash/trunk/docs
Note: You may first list the contents of the folder in terminal using svn ls /trunk/folder
(yes, that’s svn here. apparently in 2016 you still need svn to simply download some github files)
You can use Github Contents API to get an archive link and tar to retrieve a specified folder.
Command line:
curl https://codeload.github.com/[owner]/[repo]/tar.gz/master | \ tar -xz —strip=2 [repo]-master/[folder_path]
For example,
if you want to download examples/with-apollo/ folder from zeit/next.js, you can type this:
Use GitZip online tool. It allows to download a sub-directory of a github repository as a zip file. No git commands needed!
How to download a specific folder from a GitHub repo
Here a proper solution according to this post:
Create a directory
Set up a git repo
Configure your git-repo to download only specific directories
How to Download a single folder, directory or partial repo from a GitHub repo
Well, Most of the times I see hundreds of projects in a single repo. Now, if I don’t want to download a GB of code and then eventually use just 20mb of it. How is it fare?
So I wanted to create a downloader for it. Turns out I’m a little too late. There are already a couple of options which work flawlessly.
Go ahead and give it a try!
Git doesn’t support this, but Github does via 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.
Here’s how you can use this feature to download a specific folder. I’ll use the popular javascript library lodash as an example.
- Get the repo URL. First, copy the URL of the Github repo to your clipboard.
- Modify the URL for subversion. I want to download the folder at /docs from the master branch, so I will append trunk/docs . Full URL is now https://github.com/lodash/lodash/trunk/docs . See my note below for a more in-depth explanation of why we must use this URL format.
- Download the folder. Go to the command line and grab the folder with SVN. svn checkout https://github.com/lodash/lodash/trunk/docs
You might not see any activity immediately because Github takes up to 30 seconds to convert larger repositories, so be patient.
- If you’re interested in master branch, use trunk instead. So the full path is trunk/foldername
- If you’re interested in foo branch, use branch/branchname instead. The full path looks like branch/branchname/foldername
- Protip: You can use svn ls to see available tags and branches before downloading if you wish
That’s all! Github supports more subversion features as well, including support for committing and pushing changes.
How to download a single folder of a github repository
Read this article in other language
Download with Git
You can’t do it. Unlike Subversion, where each subdirectory can be checked out individually, Git operates on a whole-repository basis. For projects where finer-grained access is necessary, you can use submodules — each submodule is a separate Git project, and thus can be cloned individually.
But if a project wasn’t configured so from the beggining, you’re not able to do it.
Solution
To download a folder, we are not going to use Git, we are going to use SVN instead, yes ! Subversion will do the trick for you, just follow the following steps (you need to have svn installed on your machine and svn environment variable needs to be available in the command prompt):
1) If you are a windows user
In your windows command prompt, if an alert says that svn is not defined, you need to declare a environment variable with the following value in the System Environment Variables, go to control panel > system and security > system > Environment variables > new
Now we are going to simply use the svn checkout command from the command prompt, in this example, we are going to download the following folder from a xamarin repository. This repository has too many things that i don’t need, and i cannot download a .zip file from this folder, therefore we are going to use subversion to clone only this folder.
Now, the svn checkout command will expect :
But if you try to checkout with the normal URL, svn will not found any repo there. To fix this, you only need to replace tree/master from the url and replace it with trunk.
Finally, try executing the previous command with the final url :
And everything should be now located in the folder where you executed the command.
Скачать отдельные файлы из GitHub
Я думаю, большинство из вас, разработчики, используют любой VCS, и я надеюсь, что некоторые из вас используют Git. У вас есть какой-либо совет или трюк, как получить URL-адрес загрузки для одного файла в репозитории?
Я не хочу URL для отображения raw-файла; в случае двоичных файлов это ни для чего.
можно ли вообще использовать GitHub в качестве » скачать сервер»?
Если мы решим перейти на код Google, здесь представлена упомянутая функциональность?
или есть ли бесплатный хостинг и VCS для проектов с открытым кодом?
26 ответов:
Git не поддерживает загрузку частей репозитория. Вы должны скачать все. Но вы должны быть в состоянии сделать это с GitHub.
при просмотре файла он имеет ссылку на» сырую » версию. Элемент URL построена так
заполнив пробелы в URL, вы можете использовать Wget или cURL (С -L опция, см. ниже) или что угодно, чтобы загрузить один файл. Опять же, вы не получите ни одного из приятные особенности контроля версий используется Git с этим.
обновление: я заметил, что вы упомянули, что это не работает для двоичных файлов. Вероятно, вы не должны использовать двоичные файлы в своем репозитории Git, но GitHub имеет раздел загрузки для каждого репозитория, который вы можете использовать для загрузки файлов. Если вам нужно более одного двоичного файла, вы можете использовать a .сжатый файл. URL-адрес для загрузки загружаемого файла составляет:
обратите внимание, что URL-адреса, приведенные выше, из ссылок на github.com , будет перенаправлять к raw.githubusercontent.com . Вы не должны напрямую использовать URL-адрес, указанный этим перенаправлением HTTP 302, потому что, per RFC 2616: «поскольку перенаправление может быть изменено время от времени, клиент должен продолжать использовать запрос-URI для будущих запросов.»
- перейдите к файлу, который вы хотите скачать.
- щелкните его, чтобы просмотреть содержимое в пользовательском интерфейсе GitHub.
- в правом верхнем углу щелкните правой кнопкой мыши the .
- Сохранить как.
вы можете использовать API V3, чтобы получить raw-файл, как это (вам понадобится маркер OAuth):
curl -H ‘Authorization: token INSERTACCESSTOKENHERE’ -H ‘Accept: application/vnd.github.v3.raw’ -O -L https://api.github.com/repos/owner/repo/contents/path
все это должно идти в одну строку. Элемент -O опция сохраняет файл в текущем каталоге. Вы можете использовать -o filename , чтобы указать другое имя файла.