900

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?

Pound Hash
  • 453
  • 1
  • 4
  • 13
Radek Simko
  • 15,886
  • 17
  • 69
  • 107
  • 1
    For GitLab, see https://stackoverflow.com/a/51993087/6309. – VonC Aug 23 '18 at 19:34
  • This wont work for everyone but if you use python pandas you can simply do something like this (works for big files too): click "view raw" and then copy the url from the browser then simply do this: df = pd.read_csv( 'https://raw.githubusercontent.com/t-davidson/hate-speech-and-offensive-language/master/data/labeled_data.csv' ) – Graham Hesketh May 24 '19 at 09:56
  • Try [Gitzip for github](https://chrome.google.com/webstore/detail/gitzip-for-github/ffabmkklhbepgcgfonabamgnfafbdlkn?hl=en) for chrome – subtleseeker Jun 16 '19 at 19:09
  • Here's the simplest command-line answer **for sure**! https://unix.stackexchange.com/questions/228412/how-to-wget-a-github-file/387912#387912. Use `wget full_url_to_raw_file_on_github`. – Gabriel Staples May 25 '20 at 06:53
  • The fact that 654 people have asked the question (upvoted it) implies that GitHub has a MAJOR UI problem that needs to be resolved.. Click on the checkbox next to it and select 'download' .. Oh, doesn't exist? How absurd. (OH, and also, consider that 962,000 times someone came to this page looking for an answer! Getting a million page views for a feature would be good, bug? No) – Traderhut Games Sep 25 '20 at 16:55
  • Download file using the new [GIthub Code Preview file download](https://docs.github.com/en/repositories/working-with-files/managing-files/navigating-files-with-the-new-code-view) option, here is the demo https://stackoverflow.com/a/75601738/4936904 – Pavneet_Singh Mar 01 '23 at 09:29

40 Answers40

833
  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...
bearfriend
  • 10,322
  • 3
  • 22
  • 28
  • 55
    Instead of "Save as", copy the URL. Thats the URL of the file. You can now download it with any tool that use the URL to download: wget, your browser, etc. – jgomo3 Apr 08 '13 at 15:03
  • 1
    @MattParkins I just tried it and I think it DOES work now for large files (even binary file with the "we can't show files that are this big right now" warning) – lmsurprenant Oct 23 '13 at 13:38
  • 9
    This worked fo a single C# file. Perhaps github should add another button for downloading. Right clicking a button is not very intuitive. – Nick Mar 31 '16 at 07:23
  • Perfect for most source code files as they rarely exceed the size threshold. – Paulo Carvalho Nov 06 '18 at 10:27
  • Just a reminder. Copy the URL of the raw file, i.e. after clicking the Raw option. – Fei Yao Sep 05 '19 at 15:32
  • "Save as" -- that's what I was looking for – Minnie Feb 03 '21 at 02:45
  • Does not work if you don't have a desktop environment. – theerrormagnet May 21 '22 at 15:33
  • @theerrormagnet It actually does. The "raw" link is probably under the three dots "menu" button. Long press that link and you'll have a "download" option. – bearfriend May 25 '22 at 19:31
746

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

Community
  • 1
  • 1
jonescb
  • 22,013
  • 7
  • 46
  • 42
  • You can actually download only parts of a repository (in terms of history) using `--depth`. However, it will break further synchronization with the initial repository (since it effectively re-builds a different history). – Bruno Nov 16 '11 at 11:20
  • 23
    Note for posterity: I just tested it and using raw works fine for binary files. – emmby Dec 23 '12 at 17:11
  • 1
    tried for a ~10 MB zip file got error: Error: blob is too big – ina Feb 16 '13 at 10:37
  • @ina I've been able to get this to work for slightly smaller than 10 MB compressed binaries. GitHub has made it clear on their [disk quota page](https://help.github.com/articles/what-is-my-disk-quota) and their [downloads tab deprecated blog post](https://github.com/blog/1302-goodbye-uploads) that they want to version/store binaries as minimally as possible. – Paul 'Joey' McMurdie Mar 09 '13 at 03:49
  • 40
    The suggested URL format doesn't work for me. I find that [https://raw.github.com/user/repository/branch/filename](https://raw.github.com/user/repository/branch/filename) works. – Brian C. Mar 27 '13 at 15:57
  • 5
    @BrianC.: (At least as of 27 August 2013) the URL format mentioned in the answer (`raw` after the repository name) is now automatically redirected to the format you mention (hostname `raw.github.com`). When in doubt, browse to the file in question on github.com and click on the 'Raw' button. – mklement0 Aug 27 '13 at 20:50
  • if you only want to download directly in chrome, [Github Mate](https://github.com/camsong/chrome-github-mate) is the easy way to go. – Cam Song Dec 17 '13 at 14:35
  • 12
    if you still want to use curl, follow the redirection using the -L option on the command line: curl -L -O https://github.com/user/repository/raw/branch/filename – Lynx-Lab Dec 31 '14 at 08:21
  • 1
    I tried this, but the link opens the file in a new browser window. How can I force download the file? – finstats Nov 22 '15 at 13:13
  • **Example:** When you want to download latest `.htaccess` for Drupal 7, go to its _Github.com_ [page](https://github.com/drupal/drupal), copy the link `https://github.com/drupal/drupal/blob/7.x/.htaccess` and change it to `https://raw.githubusercontent.com/drupal/drupal/7.x/.htaccess` (change `domain`, `subdomain` and remove `blob`). – Jasom Dotnet Jun 28 '16 at 13:42
  • Do some of you know if bitBucket offers something like this http://github/user/repository/raw/branch/filename URL? – Ed de Almeida Jul 02 '16 at 17:28
  • why is RAW out of date with my source file? – SuperUberDuper Sep 19 '16 at 21:36
  • I used wget to download jar files, but each time downloaded a file which is a html page of login to the bitbucket. Do I have to specify bitbucket username/password whenusing wget? – CCNA Aug 22 '17 at 20:02
  • Do not forget `--no-check-certificate` as parameter with `wget` – Timo Oct 19 '17 at 11:05
  • @jonescb this `https://raw.githubusercontent.com/downloads/al2helal/ThesisWork/master/consecutive7pointUp36.output` **404:file not found**. Actual file is [here](https://github.com/al2helal/ThesisWork/blob/master/consecutive7pointUp36.output) – alhelal Oct 23 '17 at 02:39
  • http://githubenterprise.xyz.com/raw/user/repo/master/File1 Worked for me. – user4321 Oct 27 '17 at 15:39
  • I'm trying to download an xml file, using wget, it downloads the document as an .xml but the format of the contents is .html.......any suggestions? – alkey Apr 09 '18 at 12:40
  • How do you achieve this when cloning using SSH? – 170730350 Jun 05 '18 at 11:47
  • 2
    Does this still work? I've been doing this for months... but something just changed in the last few weeks. Now I have to include the token at the end or I get a 404 when downloading files from https://raw.githubusercontent.com/.... Used to work when sending authentication with the download request. – AndrewRalon Nov 04 '19 at 16:48
  • It would be great if Github support params on the raw url like ?download=1 – Beeno Tung Jan 15 '20 at 05:00
  • I'll add this answer for those who want to do this using postman. 1-go to the Github URL of the file which you wanna download,2-click on raw,3-copy the URL, 4- paste it in postman and make a get request to it, 5- feel free to change the type to text/XML/JSON after making a get request ,6 -click on save the response and save it with your desirable file extension. – kevin godfrey Jul 14 '21 at 01:36
  • What is the [github downloads url](https://github.com/downloads) for, I never saw it. – Timo Feb 22 '23 at 13:45
  • You should edit your answer and add that `wget github.com/user/repo/file` without `raw` downloads the html view of the file, but not the file itself. – Timo Feb 22 '23 at 13:49
104

Go to DownGit - Enter Your URL - Simply Download

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


Download with DownGit


You can download individual files and directories as zip, and also create download link.

Disclaimer: I am the author of this tool.

Minhas Kamal
  • 20,752
  • 7
  • 62
  • 64
59

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

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

Neuron
  • 5,141
  • 5
  • 38
  • 59
thomasfuchs
  • 5,386
  • 2
  • 18
  • 38
  • 8
    This one is good, but unfortunately it only supports files up to 1 MiB in size. – Per Lundberg Aug 06 '14 at 08:23
  • 2
    If executing this within a program, be sure User-Agent is set. – Aaron Silverman Oct 29 '14 at 21:28
  • 2
    Can you give some examples of the path. If you repo is my-repo and the file you want to get is at x/y/z.txt then the URL would be... It was hard to figure out that /owner/repo/ should be filled in by me. Thanks. – Gray Sep 21 '16 at 19:07
  • This works fine but there is a drawback. You don't always the latest version of a file. Try to make a modification to a file, don't wait too much and try to retrieve the file using this method. You will get just the previous version instead. – pacomix Apr 11 '17 at 10:42
  • upvoting for the -O flag, as that's the easiest when downloading from a public repo – blackpearl Jul 28 '20 at 12:45
56

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
Ted Cox
  • 661
  • 5
  • 2
  • I used `wget` followed by the raw path to the C source file I wanted after viewing the file in the github repository and clicking the Raw button. Worked like a champ with Raspbian on my Raspberry Pi 3. – Richard Chambers Dec 25 '17 at 21:12
  • I'm a bit late to the game, but this worked perfectly for me. Viewing the raw content and then right-clicking to download didn't work for my case because I needed the file in a specific format, which wasn't offered by my computer. The commands in this answer download everything as is though. – Sean Jul 23 '19 at 01:02
33

You can use curl this way:

curl -OL https://raw.githubusercontent.com/<username>/<repo-name>/<branch-name>/path/to/file

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

Mark
  • 5,994
  • 5
  • 42
  • 55
20

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/<username>/<repo>/some_directory/file.rb

Using wget you can grab the raw file from:

https://raw.github.com/<username>/<repo>/<branch>/some_directory/file.rb

Rails Composer is a great example of this.

Joe Leo
  • 400
  • 5
  • 12
16

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

GitHub Mate Download

Cam Song
  • 2,956
  • 1
  • 22
  • 18
  • 1
    @jcollum Checked just now, works for me. Can you make sure you are using the latest version? or let me know the error. Glad to help you to make it work. – Cam Song Apr 12 '14 at 07:14
  • 2
    I am on the newest version of Chrome, 34.0.1847.116, and this surely does not work. What operating system are you using? Im on OS X Mavericks. – Jahkobi Digital Apr 14 '14 at 23:05
  • I tested on Chrome 34 in Windows 7 and OS X Mavericks, both work. quite strange if not work huh? Please aware that folder are not downloadable. Maybe you can try on a different machine. – Cam Song Apr 15 '14 at 13:28
  • ok, that method will only work if you have chrome extension. https://chrome.google.com/webstore/detail/github-mate/baggcehellihkglakjnmnhpnjmkbmpkf – humazed Aug 18 '15 at 11:36
  • From this view, simply right-click and save as the file – Thierry Dalon Sep 30 '19 at 09:19
  • THERE IS NO LINK ON ICON THEN HOW TO DOWNLOAD? – Kamlesh Dec 27 '21 at 16:13
14

2019 Summary

There are a variety of ways to handle this, depending on how large the file is, whether or not you need to download folders in addition to files, and if you plan to do this manually or programmatically.

There are six options summarized below. And for those that prefer a more hands-on explanation, I've put together a YouTube video: Download Individual Files and Folders from GitHub.

Also, I've posted a similar answer on StackOverflow for those that need to download single folders/directories from GitHub (as opposed to files).


1. GitHub User Interface

  • There's a download button on most images.
  • There's a download button on the repository's homepage. Of course, this downloads the entire repo, after which you would need to unzip the download and then manually drag out the specific files you need.

2. Browser Context Menu

  • Go to the file on GitHub, right click on the "Raw" button to open the browser's context menu. From there, if you're using Google Chrome, select "Save Link As...". Other browser's will have a similar UI, but the selection description may vary. For example, it will be listed as "Download Linked File" and "Download Linked File As" on Safari.

3. Third Party Tools

  • There are a variety of browser extensions and web apps that can handle this, with DownGit being one of them. Simply paste in the GitHub URL to the file and press the "Download" button. Note that the link should be the GitHub.com hosted repository view, as opposed to the direct file link. File link example: https://github.com/babel/babel-eslint/blob/master/lib/parse.js.

4. Subversion

  • GitHub does not support git-archive (the git feature that would allow us to download specific files). GitHub does however, support a variety of Subversion features, one of which we can use for this purpose. Subversion is a version control system (an alternative to git). You'll need Subversion installed. Grab the GitHub URL for the file you want to download. You'll need to modify this URL, though. You want the link to the repository, followed by the word "trunk", and ending with the path to the nested file. In other words, using the same file link that I mentioned above, we would replace "blob/master" with "trunk". Finally, open up a terminal, navigate to the directory that you want the content to get downloaded to, type in the following command (replacing the URL with the URL you constructed): svn export https://github.com/babel/babel-eslint/trunk/lib/parse.js, and press enter.

5. cURL

  • You'll need cURL installed. Go to the file on GitHub.com, left click on the "Raw" button to get to the direct file link, copy this URL, open a terminal, navigate to the directory that you want the content to get downloaded to, type in the following command, replacing the filename with whatever you want to name it, and replacing the URL with the one you just copied: curl -o parse.js https://raw.githubusercontent.com/babel/babel-eslint/master/lib/parse.js.

6. GitHub API

  • This is actually what DownGit is using under the hood. Using GitHub's REST API, make a GET request to the content endpoint. The endpoint can be constructed as follows: https://api.github.com/repos/:owner/:repo/contents/:path. After replacing the placeholders, an example endpoint is: https://api.github.com/repos/babel/babel-eslint/contents/lib/parse.js. This gives you JSON data for that file, including a download URL (the same download URL that we used in the cURL example above). This method isn't all that useful for a single file, though (you'd be more likely to use it for downloading a specific folder, as detailed in the answer that I linked to above).
jabacchetta
  • 45,013
  • 9
  • 63
  • 75
  • its my understanding that download buttons do not download the entire repo...i could be wrong. here's an example: https://github.com/googleapis/google-api-php-client/ if you download the repository, you won't get the examples directory; you have to change branches to do that. – albert Feb 27 '20 at 20:59
  • 1
    @albert Good catch. That's actually because they specifically excluded specific folders/files in the .gitattributes file: https://github.com/googleapis/google-api-php-client/blob/master/.gitattributes – jabacchetta Feb 27 '20 at 21:17
  • In the cURL example, `-o parse.js` can be replaced with `-O` to write the file with the same name as the remote file. – Justin Vallely Apr 25 '22 at 17:28
13

There is a chrome extension called Enhanced Github

It will add a download button directly to the right of each file.

enter image description here

13

In 2021 GitHub added a new feature of opening visual studio code right on the web. You can launch it by just pressing full stop aka period key ., when you are in any repository.

So for downloading any specific file you can launch the vscode by pressing . key then it will display all files of the repository in vscode there you can download any file you want by right click > dowload.

enter image description here

Darkstar Dream
  • 1,649
  • 1
  • 12
  • 23
10

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

Gray
  • 115,027
  • 24
  • 293
  • 354
Drew Michel
  • 133
  • 1
  • 4
10

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

DJJ
  • 2,481
  • 2
  • 28
  • 53
10
  1. On github, open the file you want to download
  2. Locate the "Raw" button adjacent to the "Blame" button
  3. Press "Alt" on your keyboard and left-click on your mouse at the same time
  4. The file will download automatically in a ".txt" format (it did for me)
  5. Change the ".txt" extension to ".csv" extension manually

This worked for me and I hope it does for you too.

Audrey Mengue
  • 169
  • 2
  • 6
9
  1. Copy page link simply
  2. In command line type: wget -L (exact copied link)
  3. Just replace blob to raw in step 2
  4. Enter
Penny Liu
  • 15,447
  • 5
  • 79
  • 98
redParrot
  • 440
  • 1
  • 7
  • 14
8

This method works for Windows as I have never used MAC so I don't know what are the alternate keys in MAC for the keys which I'm going to mention below.

Let's talk about the CSV files. IF you want to download the CSV file:

  1. Go to that particular dataset that you want to download and click on it.
  2. You will see "Raw" button on the top right side of the dataset.
  3. Press "Alt" and then left click the "Raw" button.
  4. The whole CSV will download in your system.

Remeber, you have to press Alt and left click simultaneously. Just clicking the "Raw" button will open up the CSV in the browser.

I hope that helps.

saadi123
  • 614
  • 1
  • 8
  • 12
7

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

Kevin Delord
  • 2,498
  • 24
  • 22
7

GitHub Releases feature

Rather than link to download a specific file within the repo, you should use GitHub's Releases feature to associate downloadable data (such as compiled binaries) with the tagged version of the source code used to generate that data.

https://github.com/blog/1547-release-your-software

We're excited to announce Releases, a workflow for shipping software to end users. Releases are first-class objects with changelogs and binary assets that present a full project history beyond Git artifacts.

Releases are accompanied by release notes and links to download the software or source code.

Following the conventions of many Git projects, releases are tied to Git tags. You can use an existing tag, or let releases create the tag when it's published.

enter image description here

Community
  • 1
  • 1
pkamb
  • 33,281
  • 23
  • 160
  • 191
  • 2
    Yes! This is the simplest solution, doable right from your browser! 1. From your repository main page, select `releases` 2. Click on the commit number. 3. Find the file you want, click on the three dots `...` and select `View file` 4. Click on `View raw` to download the file!!! – Jonathan Benn May 22 '20 at 15:43
5

Simply use wget with raw=True parameter

wget "https://github.com/user/repository/blob/master/directory/file_name?raw=True" -O target_path/file_name
Claude COULOMBE
  • 3,434
  • 2
  • 36
  • 39
4

To download a file from a Github repo, use the 'curl' command with the link to the raw file.

curl https://raw.githubusercontent.com/user/repo/filename --output filename

Add the --output option followed by the new filename to download the raw file to the newly created file.

George
  • 121
  • 1
  • 5
3

This would definitely work. At least in Chrome. Right click on the "Raw" icon -> Save Link As.

Franz Holzinger
  • 913
  • 10
  • 20
Ankish Jain
  • 11,305
  • 5
  • 36
  • 34
  • 1
    This saves the HTML file of the github page, which includes the github wrapper around the file. – Gregor Thomas Jan 07 '16 at 20:16
  • @Gregor - FYI, It shouldn't, at least for pages that are TEXT. If in doubt, LEFT-click on the "Raw" icon. This should open the text file in browser, WITHOUT any HTML. Now rt-click anywhere on page, and do "Save As...". (Or do Select-All / Copy, then Paste wherever you want) – ToolmakerSteve Apr 15 '17 at 21:13
2

I recently found a service called gitzip and its also open source:

site - http://kinolien.github.io/gitzip/

repo - https://github.com/KinoLien/gitzip

Vist the above site, enter the repo or directory URL, you can download individual files or whole directory as a zip file.

avi
  • 9,292
  • 11
  • 47
  • 84
  • But how do I only download `jszip.min.js` from that repository? *troll face* – Levi Fuller Jun 22 '16 at 18:16
  • open the file in github and then go to raw. You should see then the source code of the file and then you can download it useing the browser with right click mouse and save as. It works for me. – Boris Jul 11 '16 at 20:18
2

Now it's possible to download any file or any particular folder within the repository using this google chrome extention:

GitZip for github : link : https://chrome.google.com/webstore/detail/gitzip-for-github/ffabmkklhbepgcgfonabamgnfafbdlkn

Usage :

  1. In any GitHub public repos page.
  2. Just double click on the items you need.
  3. Click download button at bottom-right.
  4. See the progress dashboard and wait for browser trigger download.
  5. Get the ZIP file.

enter image description here

enter image description here

Natesh bhat
  • 12,274
  • 10
  • 84
  • 125
2
  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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
bmargulies
  • 97,814
  • 39
  • 186
  • 310
2

On a Mac or Linux install jq and use it to extract the file from Github like this:

curl -H 'Authorization: token <ACCESS_TOKEN>' \
   -H "Accept: application/vnd.github.v3+raw" -L \
   https://api.github.com/repos/MY-ORG/MY-REPO/contents/MY-FILE-PATH | \
   jq -r '.content' | base64 --decode > MY_FILE_NAME.txt

Documentation for the above command can be found here.

Freddie
  • 908
  • 1
  • 12
  • 24
1

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

git file

raw

Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71
Francis Smart
  • 3,875
  • 6
  • 32
  • 58
  • 1
    Sometimes the raw url is like this instead (raw.githubusercontent.com): https://raw.githubusercontent.com/warpech/jquery-handsontable/master/dist/jquery.handsontable.full.js – jcollum Mar 20 '14 at 18:05
1

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.

estani
  • 24,254
  • 2
  • 93
  • 76
1

Go to the script and click "Raw"

Then copy the link and download it with the aria2c link.

Eg: aria2c https://raw.githubusercontent.com/kodamail/gscript/master/color.gsf

Trick: the file I wanted to download is, https://github.com/kodamail/gscript*/blob*/master/color.gsf

just modify the link into https://raw.githubusercontent.com/kodamail/gscript/master/color.gsf

Remove the italic texts and add bold texts in the same format, it will give you the right link.

which can be used with aria2c,wget or with curl, I used aria2c here.

Krishnaap
  • 297
  • 3
  • 18
1

My simple way to do it is:

  1. click the 'Raw' button to get the file contents of github_csv.csv shown on the browser.
  2. Then create file.csv and open it in a text editor like notepad
  3. Then copy the file content from the website and paste it on the file.csv
  4. Your file.csv is github_csv.csv
1

I. If you wanner download a file like a .so other than source code, try click Download button as below:

enter image description here

The file will download tru your browser.

II. If u want to download source code, click Raw and will go to the raw.. page, enter image description here

Simple copy/paste or use curl or wget command to get it in your terminal.

malajisi
  • 2,165
  • 1
  • 22
  • 18
1

you can copy the content of the GitHub file then paste it in your file. SIMPLE!

hasan darwish
  • 117
  • 1
  • 6
0
  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
Gray
  • 115,027
  • 24
  • 293
  • 354
Evan Gertis
  • 1,796
  • 2
  • 25
  • 59
0

For users with GitHub Enterprise you need to construct URL in following scheme

Invoke-WebRequest http://github.mycompany.com/api/v3/repos/my-org/my-repo/contents/myfiles/file.txt -Headers @{"Authorization"="token 8d795936d2c1b2806587719b9b6456bd16549ad8"}

Details can be found here

http://artisticcheese.blogspot.com/2017/04/how-to-download-individual-files-from.html

Gregory Suvalian
  • 3,566
  • 7
  • 37
  • 66
0

Or try this

const https = require('https');
const fs = require('fs');
const DOMAIN = 'raw.githubusercontent.com';

function writeFile(data, fileName) {
  fs.appendFile(fileName, data.toString(), err => {
    if (err) {
      console.log('error in writing file', err);
    }
  });
}

function EOF(data) {
  console.log('EOF');
}

function getFileName(pathToFile) {
  var result = pathToFile.split('/');
  var splitLength = result.length;
  return result[splitLength - 1];
}
function getFile(branchName, username, repoName, ...pathToFile) {
  pathToFile.forEach(item => {
    const path = `/${username}/${repoName}/${branchName}/${item}`;
    const URL = `${DOMAIN}${path}`;
    const options = {
      hostname: DOMAIN,
      path: path
    };
    var fileName = getFileName(item);

    https
      .get(options, function(res) {
        console.log(res.statusCode);
        /* if file not found */
        if (res.statusCode === 404) {
          console.log('FILE NOT FOUND');
        } else {
          /* if file found */
          res.on('data', data => writeFile(data, fileName));
          res.on('end', data => EOF(data));
        }
      })
      .on('error', function(res) {
        console.log('error in reading URL');
      });
  });
}
getFile('master', 'bansalAyush', 'InstagramClone', '.babelrc', 'README.md');
Ayush Bansal
  • 702
  • 1
  • 7
  • 17
0

I used the following format, and I feel it's important to inform about the path.

https://github.com/user/repository/raw/branch/filename

^^^the above is not very complete in my mind

https://github.com/<user>/<repoROOTname>/blob/master/<path>/<filename>?raw=true

some said raw.github.com or raw instead of blob, but the 2nd line works for me and I hope will help others...

rezwits
  • 835
  • 7
  • 12
0

You can try github-files-fetcher, it is a command line tool which downloads a single folder or file from a GitHub repo.

Think a real scenario: you were visiting the following webpage page and wanna download the async subdirectory alone.

https://github.com/reduxjs/redux/tree/master/examples

sorry for not being allowed to post images.

With The github-files-fetcher, you should first copy the url of that page, which is https://github.com/reduxjs/redux/tree/master/examples/async, and then run the command below in command line:

fetcher --url=https://github.com/reduxjs/redux/tree/master/examples/async

Gyumeijie
  • 174
  • 7
0

If you use npm, just run following command line and finally, it won't download any npm package except for this github file

npx config-pack https://github.com/facebook/react/blob/main/README.md

See config-pack for more details

zixiCat
  • 1,019
  • 1
  • 5
  • 17
0

Use the pattern f'{host}/{user}/{repo}/{branch}/{file}'. To have a concrete example, do in Python:

import pandas as pd
host = 'raw.github.com'
user = 'fivethirtyeight'
repo = 'data'
branch = 'master'
file = 'births/US_births_2000-2014_SSA.csv'
url = f'https://{host}/{user}/{repo}/{branch}/{file}'
df = pd.read_csv(url,sep=',',header=0)
df.head()
Maciej Skorski
  • 2,303
  • 6
  • 14
0

New Github Code Preview File Download Option

The new code preview feature on github allows to download a file directly without any extension or workaround. Steps to enable:

  1. In the upper-right corner of any page, click your profile photo, then click Feature preview.
  2. To the right of "New Code Search and Code View (Beta)", click Enable or Disable.
  3. Refresh current page
  4. Click on download raw file

enter image description here

Pavneet_Singh
  • 36,884
  • 5
  • 53
  • 68
-4

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

tested with a php file that i downloaded just now (at time of answer)

Community
  • 1
  • 1
Learner
  • 11