- Скачать отдельные файлы из GitHub
- 26 ответов:
- How do I download a particular file from GitHub?
- 5 Answers 5
- Download file from github windows
- About
- How to download GitHub Release from private repo using command line
- 7 Answers 7
- Is there a link to GitHub for downloading a file in the latest release of a repository?
- 18 Answers 18
- tl;dr — more details below
- Solution for atom releases
- Get the names of the assets published
- Get the download URL for the desired asset
- Download the artifact
- jq Playground
- Security
- TESTING:
- DIRECT:
- INDIRECT:
- Preferred Method:
- Further Validation:
- DIRECT:
- INDIRECT:
Скачать отдельные файлы из 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 , чтобы указать другое имя файла.
How do I download a particular file from GitHub?
I only need one particular file from a project published on GitHub so it makes little sense to download the whole project. But I just can’t find the download button.
5 Answers 5
If you’re viewing the contents of the file itself there should be a «Raw» button.
- Right-click on that and select the «Save content as. » (or similar depending on your browser)
- Click through to see the contents dumped onto the screen and save from there
In the list of files, every filename is a link. A simple right-click and «Save link as. » (or equivalent for your browser) will allow you to download a single file.
This breaks down with HTML files, however. You’ll need to use the «Raw» button on the file page as Eight Days of Malaise’s answer describes. I’m using Google Chrome. You may have a different experience on a different browser.
Check out RawGit which is a free service to serve files directly from Github with proper Content-type headers.
If you are using the Chromium browser, just hold down the ALT key and left click on the file to download it.
(Doesn’t work with Mozilla Firefox, haven’t tested other browsers.)
You can try github-files-fetcher, it is a command line tool which downloads a single folder or file from a GitHub repo.
Think a real scenario: you were visiting the following webpage page and wanna download the async subdirectory alone.
Download file from github windows
Meet Files, an enthusiast take on what a modern file explorer should be.
Where to get Files
Files is a file manager which leverages the latest features of the Windows platform including Fluent Design, seamless updates, and APIs which enable the performance and lifecycle behavior that users expect. Whether you want to simplify your experience with your files or try something new, Files is a one-stop solution for exploring your files on the fly.
Vision for Files
The vision for Files is to make it the best file manager while keeping it simple and easy to use. Whether it’s implementing new features, or pushing the boundaries of the platform, your input will help shape the future of Files.
Why should I contribute?
We can confidently assert Files is the platform’s best file explorer project to bring your innovations to. We focus heavily on extensibility and code modularity and have no plans to stop doing so. When you contribute to this project, you’re helping everyone by fixing reported bugs, adding new features, or correcting existing behavior. These changes are quickly included in the final product for all users to benefit from.
Building Files source
- Install Visual Studio 2019 and the UWP Development Kit.
- Clone the repository and open the Files.sln in VS.
- Visual Studio will install all missing dependencies.
- Run the Files.Package project.
Have any questions? Check out our documentation site!
About
A modern file explorer that pushes the boundaries of the platform.
How to download GitHub Release from private repo using command line
GitHub guide explains 2 way to authorize but looks neither of those works with the Release files.
curl -u ‘username’ -L -o a.tgz https://github.com/company/repository/releases/download/TAG-NAME/A.tgz
there always is something like
7 Answers 7
To download release file from private repo, you can use Personal access token which can be generated at settings/tokens with Full control of private repositories scope.
Then download the asset with curl command (change with appropriate values):
or if you’re using an OAuth app, use:
- :owner is your user or organisation username;
- :repo is your repository name;
:id is your asset id, can be found in tag release URL, like:
:token is your personal access token (can be created at /settings/tokens ;
Note: Using access_token as a query param is deprecated.
Here is the Bash script which can download asset file given specific name of file:
Before running, you need to set your GITHUB_API_TOKEN with your GitHub token (see: /settings/tokens at GH). This can be placed in your
/.secrets file, like:
Example script usage:
where name is your filename (or partial of it). Prefix script with TRACE=1 to debug it.
In case you wonder why curl fails sometimes with (as mentioned in other answer):
Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified.
when running like:
this is because you’re specifying multiple mechanism at the same time, so S3 server doesn’t know which one to use, therefore you have to choose only one, such as:
- X-Amz-Algorithm query parameter
- Signature query string parameter ( X-Amz-Signature )
- Authorization header ( Authorization: token )
and since GitHub redirects you from asset page (when requesting application/octet-stream ), it populates credentials automatically in query string and since curl is passing over the same credentials in the request header (which you’ve specified), therefore they’re conflicting. So as for workaround you can use access_token instead.
Is there a link to GitHub for downloading a file in the latest release of a repository?
Using GitHub’s Release feature, it is possible to provide a link to download a specific version of the published software. However, every time a release is made, the gh-page also needs to be updated.
Is there a way to get a link to a specific file of whatever the latest version of a software is?
e.g., this would be a static link:
What I’d like is something like:
NOTE: The difference between this question and GitHub latest release is that this question specifically asks for getting access to the file, not the GitHub latest release page
18 Answers 18
A few years late, but I just implemented a simple redirect to support https://github.com/USER/PROJECT/releases/latest/download/package.zip . That should redirected to the latest tagged package.zip release asset. Hope it’s handy!
Linux solution to get latest release asset download link (works only if release has one asset only)
You can do an ajax request to get latest release download URL using the GitHub Releases API. It also shows when it was released and the download count:
It is important for you to set the default button URL to the releases page (like https://github.com/ShareX/ShareX/releases/latest) so if the browser does not support ajax (or javascript) or is too slow to get the URL, the download button will still work.
When the Ajax request completes, the URL of this button will change automatically to a direct download URL.
I also made a downloads page that shows multiple releases which you can find here: https://getsharex.com/downloads/
From the command line using curl and jq , retrieves the first file of the latest release:
Another Linux solution using curl and wget to download a single binary file from the latest release page
curl -s -L is to silently download the latest release HTML (after following redirect)
egrep -o ‘. ‘ uses regex to find the file you want
wget —base=http://github.com/ -i — converts the relative path from the pipeline to absolute URL
and -O scollector sets the desired file name.
may be able to add -N to only download if the file is newer but S3 was giving a 403 Forbidden error.
Just use one of the urls below to download the latest release: (took urls from boxbilling project for example): https://api.github.com/repos/boxbilling/boxbilling/releases
Click on one of the urls to download the latest release instantly. As i wrote this lines it’s currently: boxbilling-boxbilling-4.20-30-g452ad1c[.zip/.tar.gz]
UPDATE: Found an other url in my logfiles (ref. to example above) https://codeload.github.com/boxbilling/boxbilling/legacy.tar.gz/master
As noted previously, jq is useful for this and other REST APIs.
tl;dr — more details below
Assuming you want the macOS release:
Solution for atom releases
Note each repo can have different ways of providing the desired artifact, so I will demonstrate for a well-behaved one like atom.
Get the names of the assets published
Get the download URL for the desired asset
Below atom-mac is my desired asset via jq’s select(.name==»atom-mac.zip»)
Download the artifact
jq Playground
jq syntax can be difficult. Here’s a playground for experimenting with the jq above: https://jqplay.org/s/h6_LfoEHLZ
Security
You should take measures to ensure the validity of the downloaded artifact via sha256sum and gpg, if at all possible.
A solution using (an inner) wget to get the HTML content, filter it for the zip file (with egrep) and then download the zip file (with the outer wget).
Not possible according to GitHub support as of 2018-05-23
Contacted support@github.com on 2018-05-23 with message:
Can you just confirm that there is no way besides messing with API currently?
and they replied:
Thanks for reaching out. We recommend using the API to fetch the latest release because that approach is stable, documented, and not subject to change any time soon:
Python solution without any dependencies
Robust and portable:
Also consider pre-releases
/latest does not see pre-releases, but it is easy to do since /releases shows the latest one first:
The Linking to releases help page does mention a «Latest Release» button, but that doesn’t get you a download link.
For that, you need to get the latest tag first (as mentioned in «GitHub URL for latest release of the download file?»):
Github now supports static links for downloading individual files from the latest release: https://help.github.com/en/articles/linking-to-releases
in PHP — redirect to the latest release download. Simply put on your webspace
If you want to use just curl you can try with -w ‘%
The benefit of this solution is that you don’t have to specify any release or tag number- it will just grab the LATEST.
TESTING:
I conducted my testing using the following Github user & repo:
«f1linux» = Github User
«pi-ap» = Repo
The arbitrary directory name the repo is saved to is set in:
DIRECT:
Using Firefox’s «Web Developer» tools (3 bars in upper right corner), in the «Network» section I found https://api.github.com was redirecting to https://codeload.github.com , so by piping the curl to tar I was able to grab the latest versioned repo and save it to a predictable name so it could be operated on:
INDIRECT:
After I achieved fully-automated downloads of the latest versioned release using a DIRECT URL, I turned my attention to achieving the same with Github’s redirection:
Preferred Method:
However, please note as per Von’s comment below that INDIRECT is the preferred method
Further Validation:
To ensure my results were reproducible to other versioned Github repos, the same tests were successfully executed for Digital Ocean’s doctl api toolkit (which is what started the whole exercise actually!):
Both DIRECT and INDIRECT work using the same form as above, just changing the username & repo:
DIRECT:
INDIRECT:
I want to download the releases from the README.md file in the repository description. There, I cannot execute JavaScript.
I can add links like these to the README file or github pages for all of my repositories:
- https://niccokunzmann.github.io/download_latest/ / /
Downloads the latest release file from the repository. - https://niccokunzmann.github.io/download_latest/
This works because the JavaScript referrer is set and the repository to download is determined through document.referrer . Thus, the link will also work for forks.
You can find the source code here, fork or just use my repo.
This is for Linux.
I saw the above accepted answer
by Joshua Peek but a comment noted it didn’t support versioned file names.
After searching for a bit, I made up a one line call that works for versioned file names. It uses curl to get the latest file version and then makes use of the redirect support that was added to download the latest versioned file.