Download single files 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"?

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?

11/25/2015 10:10:47 AM

Accepted Answer

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, will redirect to 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."

4/17/2019 1:40:34 PM

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

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:

I've written this up as a gist as well:


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 file contents.
  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/

    One more: in RHEL7.6, run the following:

    • wget https://URL-from-step3/ --output-document=FILE_NAME

Go to DownGit - Enter Your URL - Simply Download

No need to install anything or follow complex instructions; specially suited for large source files.

Disclaimer: I am the author of this tool.

Download with DownGit

You can download individual files and directories as zip. You can also create download link, and even give name to the zip file. Detailed usage- here.


You can use curl this way:

curl -OL<username>/<repo-name>/<branch-name>/path/to/file

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


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

GitHub Mate Download