Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, January 30, 2016

Download single files from GitHub

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.

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?

Answer by bmargulies for Download single files from GitHub


  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.

Answer by jonescb for Download single files from GitHub


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 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://raw.githubusercontent.com/downloads/user/repository/filename  

Answer by bearfriend for Download single files from GitHub


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

Answer by fsmart for Download single files from GitHub


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

git file

raw

Answer by Joe Leo for Download single files from GitHub


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:

https://github.com///some_directory/file.rb  

Using wget you can grab the raw file from:

https://raw.github.com////some_directory/file.rb  

Rails Composer is a great example of this.

Answer by Cam Song for Download single files from GitHub


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

GitHub Mate Download

Answer by thomasfuchs for Download single files from GitHub


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

Answer by Guest for Download single files from GitHub


This is what worked for me just now...

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

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

Answer by Evan Gertis for Download single files from GitHub


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

Answer by estani for Download single files from GitHub


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.

Answer by Drew Michel for Download single files from GitHub


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

Answer by Ankish Jain for Download single files from GitHub


This would definitely work. At least in Chrome. Right click -> Save Link As.

Answer by DJJ for Download single files from GitHub


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

wget -O filename.zip https://github.com/downloads/user/repository/filename.zip?raw=true  

see this website for more details

Answer by Kevin Delord for Download single files from GitHub


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

For example to download the README of AFNetworking:

curl https://raw.githubusercontent.com/AFNetworking/AFNetworking/master/README.md > ADREADME.md   

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


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.