What are some tips on downloading a single file from a GitHub repo?
I don't want the URL for displaying the raw file; in the case of binaries, there's nothing.
http://support.github.com/discussions/feature-requests/41-download-single-file
Is it even possible to use GitHub as a "download server"?
If we decide to switch to Google Code, is the mentioned functionality presented there?
Or is there any free-of-charge hosting and VCS for open-source projects?
To download from GitHub, you should navigate to the top level of the project (SDN in this case) and then a green "Code" download button will be visible on the right. Choose the Download ZIP option from the Code pull-down menu. That ZIP file will contain the entire repository content, including the area you wanted.
GitHub lets you download one file from a repository. This is a useful feature because it means you do not have to clone or retrieve an entire repository to download a particular file. You cannot retrieve a single file using the git command line, even if your repository is hosted on GitHub.
Raw
button.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."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With