Download single files from GitHub
Go to DownGit - Enter Your URL - Simply Download
No need to install anything or follow complex instructions; especially suited for large source files.
You can download individual files and directories as zip, and also create download link.
Disclaimer: I am the author of this tool.
- Go to the file you want to download.
- Click it to view the contents within the GitHub UI.
- In the top right, right click the
Raw
button. - Save as...
According to this gist, you can use wget or cURL:
- Click the file name in a GitHub repo.
- Click Raw to display the file contents.
- Copy the URL in your browser.
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
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
https://raw.githubusercontent.com/user/repository/branch/filename
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:
https://github.com/downloads/user/repository/filename
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."