How To Download A File From Github

I guess most of you, developers, use any VCS, and I hope some of you use Git. Do you have any tip or trick how to get a download URL for a single file in a repository?

I don't want the URL for displaying the raw file; in case of binaries it's for nothing.

Is it even possible to use GitHub as a 'download server'?

Jan 8, 2019 - If you do click on it, you will likely get a copy of the file downloaded. Instead, right click and select 'copy link'. Then paste the link in to the.

If we decide to switch to Google Code, is the mentioned functionality presented here?

Or is there any free-of-charge hosting and VCS for open-source projects?

Radek SimkoRadek Simko

26 Answers

Git does not support downloading parts of the repository. You have to download all of it. But you should be able to do this with GitHub.

When you view a file it has a link to the 'raw' version. The URL is constructed like so

By filling in the blanks in the URL, you can use Wget or cURL (with the -L option, see below) or whatever to download a single file. Again, you won't get any of the nice version control features used by Git by doing this.

Update: I noticed you mention this doesn't work for binary files. You probably shouldn't use binary files in your Git repository, but GitHub has a download section for each repository that you can use to upload files. If you need more than one binary, you can use a .zip file.The URL to download an uploaded file is:

Note that the URLs given above, from the links on github.com, will redirect to raw.githubusercontent.com. You should not directly use the URL given by this HTTP 302 redirect because, per RFC 2616: 'Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests.'

jonescbjonescb
  1. Go to the file you want to download.
  2. Click it to view the contents within the GitHub UI.
  3. In the top right, right click the Raw button.
  4. Save as...
How to download a file from github to kodi
bearfriendbearfriend

You can use the V3 API to get a raw file like this (you'll need an OAuth token):

curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path

All of this has to go on one line. The -O option saves the file in the current directory. You can use -o filename to specify a different filename.

To get the OAuth token follow the instructions here:https://help.github.com/articles/creating-an-access-token-for-command-line-use

I've written this up as a gist as well:https://gist.github.com/madrobby/9476733

thomasfuchsthomasfuchs

How To Download A File From Github To Install

According to this gist, you can use wget or cURL:

  1. Click the file name in a GitHub repo.
  2. Click Raw to display the filecontents.
  3. Copy the URL in your browser.
  4. In the command line, run either:
    • wget --no-check-certificate --content-disposition https://URL-from-step3/
    • curl -LJO https://URL-from-step3/
Ted CoxTed Cox

GitHub Mate makes single file download effortless, just click the icon to download, currently it only work on Chrome.

Cam SongCam Song

This is now possible in GitHub for any file. You need to translate your files for raw.github.com. For example, if your file is in your repository at:

Using wget you can grab the raw file from:

Rails Composer is a great example of this.

Joe LeoJoe Leo

To follow up with what thomasfuchs said but instead for GitHub Enterprise users here's what you can use.

curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://your_domain/api/v3/repos/owner/repo/contents/path

Also here's the API documentation https://developer.github.com/v3/repos/contents

How To Download Code From Github

Drew MichelDrew Michel

You can use curl this way:

curl -OL https://raw.githubusercontent.com/<username>/<repo-name>/<branch-name>/path/to/file

O means that curl downloads the content
L means that curl follows the redirection

MarkMark

In case you want to download a zip file from github using wget

see this website for more details

DJJDJJ

You should just do it with the raw URL of your file.

For example to download the README of AFNetworking:

As it is a public repo you don't need any credentials.Please note the kind of url: raw.githubusercontent.com/path/to/file

Kevin DelordKevin Delord

This method works for Windows as I have never used MAC so I don't know what are the alternate keys in MAC for the keys which I'm going to mention below.

Let's talk about the CSV files. IF you want to download the CSV file:

  1. Go to that particular dataset that you want to download and click on it.
  2. You will see 'Raw' button on the top right side of the dataset.
  3. Press 'Alt' and then left click the 'Raw' button.
  4. The whole CSV will download in your system.

Remeber, you have to press Alt and left click simultaneously. Just clicking the 'Raw' button will open up the CSV in the browser.

I hope that helps.

saadi123saadi123

There is a chrome extension called Enhanced Github

It will add a download button directly to the right of each file.

Abraham Murciano BenzadonAbraham Murciano Benzadon

This would definitely work. At least in Chrome. Right click on the 'Raw' icon ->Save Link As.

Ankish JainAnkish Jain
How To Download A File From Github

Rather than link to download a specific file within the repo, you should use GitHub's Releases feature to associate downloadable data (such as compiled binaries) with the tagged version of the source code used to generate that data.

We're excited to announce Releases, a workflow for shipping software to end users. Releases are first-class objects with changelogs and binary assets that present a full project history beyond Git artifacts.

Releases are accompanied by release notes and links to download the software or source code.

Following the conventions of many Git projects, releases are tied to Git tags. You can use an existing tag, or let releases create the tag when it's published.

pkambpkamb
  1. The page you linked to answers the first question.

  2. GitHub also has a download facility for things like releases.

  3. Google Code does not have Git at all.

  4. GitHub, Google Code and SourceForge, just to start, are free hosting. SourceForge might still do CVS.

bmarguliesbmargulies

I recently found a service called gitzip and its also open source:

site - http://kinolien.github.io/gitzip/

repo - https://github.com/KinoLien/gitzip

Vist the above site, enter the repo or directory URL, you can download individual files or whole directory as a zip file.

aviavi

I think the new url structure is raw.giturl for example:

fsmartfsmart

If you happen to use curl and firefox... you could use the cliget add-on which generates a curl call including all authentication mechanisms (aka cookies).

So right click on the raw button cliget->'copy url for link' and then paste that into a shell. You will get your file even if you had to log-in to see it.

estaniestani

Now it's possible to download any file or any particular folder within the repository using this google chrome extention:

GitZip for github :link : https://chrome.google.com/webstore/detail/gitzip-for-github/ffabmkklhbepgcgfonabamgnfafbdlkn

Usage :

  1. In any GitHub public repos page.
  2. Just double click on the items you need.
  3. Click download button at bottom-right.
  4. See the progress dashboard and wait for browser trigger download.
  5. Get the ZIP file.
Natesh bhatNatesh bhat

To download a file from a Github repo, use the 'curl' command with the link to the raw file.

Add the --output option followed by the new filename to download the raw file to the newly created file.

GeorgeGeorge
  1. On the right hand side just below 'Clone in Desktop' it say's 'Download Zip file'
  2. Download Zip File
  3. Extract the file
Evan GertisEvan Gertis

For users with GitHub Enterprise you need to construct URL in following scheme

Invoke-WebRequest http://github.mycompany.com/api/v3/repos/my-org/my-repo/contents/myfiles/file.txt -Headers @{'Authorization'='token 8d795936d2c1b2806587719b9b6456bd16549ad8'}

Details can be found here

Gregory SuvalianGregory Suvalian

How To Download A File From Github To Kodi

Ayush BansalAyush Bansal

I used the following format, and I feel it's important to inform about the path.

^^^the above is not very complete in my mind

some said raw.github.com or raw instead of blob, but the 2nd line works for me and I hope will help others...

rezwitsrezwits

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.

sorry for not being allowed to post images.

With The github-files-fetcher, you should first copy the url of that page, which is https://github.com/reduxjs/redux/tree/master/examples/async, and then run the command below in command line:

fetcher --url=https://github.com/reduxjs/redux/tree/master/examples/async

GyumeijieGyumeijie

This is what worked for me just now...

How To Download Xml File From Github

  1. Open the raw file in a seperate tab.

  2. Copy the whole thing in your notepad in a new file.

  3. Save the file in the extension it originally had

How To Download A File From Github Free

...worked for the .php file I DL just now.

LearnerLearner

protected by CommunityMar 22 at 14:30

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged gitversion-controlgithub or ask your own question.