Skip to content
Fix Code Error

Download single files from GitHub

March 13, 2021 by Code Error
Posted By: Anonymous

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.

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 here?

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

Solution

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.”

Answered By: Anonymous

Related Articles

  • Checkout another branch when there are uncommitted…
  • Why do I have to "git push --set-upstream origin "?
  • git pull while not in a git directory
  • Why do git fetch origin and git fetch : behave differently?
  • Git Using Remote Branch
  • Git - Pushing code to two remotes
  • How to track untracked content?
  • XSLT to combine Line Items with same ID into…
  • Why call git branch --unset-upstream to fixup?
  • How do I make a Git commit in the past?
  • What are the new features in C++17?
  • Manually hiding and showing drawer-panel in…
  • Retrieve specific commit from a remote Git repository
  • Git workflow and rebase vs merge questions
  • What's the difference between HEAD^ and HEAD~ in Git?
  • How to recover stashed uncommitted changes
  • git lfs push to github failure on Ubuntu 18.04
  • How can I find the location of origin/master in git,…
  • Various ways to remove local Git changes
  • How can I switch to another branch in git?
  • How to pull in changes from skeleton sub-repository…
  • Aurelia Custom Elements Inside of Custom Elements…
  • What is "git remote add ..." and "git push origin master"?
  • Does "git fetch --tags" include "git fetch"?
  • How to retrieve a single file from a specific…
  • How to fix Git error: object file is empty?
  • Is it safe to shallow clone with --depth 1, create…
  • Error: Can't set headers after they are sent to the client
  • Why does git perform fast-forward merges by default?
  • Git command to show which specific files are ignored…
  • In plain English, what does "git reset" do?
  • Recalculate merge conflicts (ie. how to generate…
  • Why is Git better than Subversion?
  • Git submodule update
  • Setting up and using Meld as your git difftool and mergetool
  • How to configure Git post commit hook
  • Is it possible to use pip to install a package from…
  • Homebrew install specific version of formula?
  • What's the difference between "git reset" and "git…
  • Polymer POST http://localhost:3000/ 404 (Not Found)
  • Push on GIT and Bitbucket
  • Why does Git say my master branch is "already up to…
  • How to backup a local Git repository?
  • Why did my Git repo enter a detached HEAD state?
  • ExpressJS How to structure an application?
  • Git push error: "origin does not appear to be a git…
  • Retrieve the commit log for a specific line in a file?
  • How do I clone a single branch in Git?
  • List comprehension : Double loop WITH conditions
  • Windows git "warning: LF will be replaced by CRLF",…
  • Git: Create a branch from unstaged/uncommitted…
  • Git merge with force overwrite
  • How do I remove a submodule?
  • Push git commits & tags simultaneously
  • What exactly does the "u" do? "git push -u origin…
  • Is there a way to cache GitHub credentials for…
  • Rebasing remote branches in Git
  • Importing a GitHub project into Eclipse
  • git status shows modifications, git checkout --…
  • Function runs into an error after successfully…
  • Detach (move) subdirectory into separate Git repository
  • Your configuration specifies to merge with the from…
  • Difference between git checkout --track…
  • How to git reset --hard a subdirectory?
  • How to use Git for Unity3D source control?
  • How to download and save an image in Android
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • How to upload a project to Github
  • Change a Git remote HEAD to point to something…
  • What is git tag, How to create tags & How to…
  • How do I add files and folders into GitHub repos?
  • Why does git say "Pull is not possible because you…
  • How do I delete a Git branch locally and remotely?
  • npm install error in vue
  • “tag already exists in the remote" error after…
  • Git's famous "ERROR: Permission to .git denied to user"
  • How to clone ('fork') your own personal GitHub repo…
  • Google Forms file upload complete example
  • Why am I getting a "401 Unauthorized" error in Maven?
  • Detect if Visual C++ Redistributable for Visual…
  • How to find the nearest parent of a Git branch?
  • The null object does not have a method []=
  • Remove sensitive files and their commits from Git history
  • Click triggered twice Vue.js
  • (Mac) -bash: __git_ps1: command not found
  • 'cannot open git-upload-pack' error in Eclipse when…
  • Why does Git tell me "No such remote 'origin'" when…
  • The remote end hung up unexpectedly while git cloning
  • git switch branch without discarding local changes
  • git push says "everything up-to-date" even though I…
  • apache server reached MaxClients setting, consider…
  • The definitive guide to form-based website authentication
  • Can I run HTML files directly from GitHub, instead…
  • Git push: "fatal 'origin' does not appear to be a…
  • Git merge master into feature branch
  • How can I move HEAD back to a previous location?…
  • Update Git submodule to latest commit on origin
  • How do you use "git --bare init" repository?
  • Grouped bar plot in ggplot
  • How to cherry pick a range of commits and merge into…

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Loading local JSON file

Next Post:

How to properly ignore exceptions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error