What do raw.githubusercontent.com urls represent?

I want to learn how to use rawgit.com to serve other applications from github.com . So we have the usual way to download and install homebrew on osx.

 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

I can not find the install file on GitHub. Where is it?

+17
source share
3 answers

The raw.githubusercontent.com domain raw.githubusercontent.com used to serve raw versions of files stored in GitHub repositories. If you go to the file on GitHub, then click on the Raw link where you go.

The URL of your question refers to the install file in the master Homebrew/install repository branch . The rest of this command simply extracts the file and runs ruby in its contents.

+36
source

There are two ways to view github content: raw and web pages.

raw.githubusercontent.com returns the raw contents of files stored in github, so you can simply download them to your computer. For example, if the page is a ruby ​​installation script, you will get a ruby ​​installation script that will be understood by your ruby ​​installation.

If instead you download a file using the github.com link, you will actually load a web page with buttons and comments, in which the desired script will be displayed in the right place - this is what you want to give your web browser to get a good page for viewing, but for a computer, this is not a script that can be executed or code that can be compiled, but a web page to display. This web page has a Raw button that sends you to the relevant content on raw.githubusercontent.com .

To see the contents of raw.githubusercontent.com/${repo}/${branch}/${path} in the normal github interface:

  1. you replace raw.githubusercontent.com simple github.com
  2. And you insert a "blob" between the repo name and the branch name.

In this case, the branch name is "master" (this is a very common branch name), so you replace /master/ with /blob/master/ , and so on

 https://raw.githubusercontent.com/Homebrew/install/master/install 

becomes

 https://github.com/Homebrew/install/blob/master/install 

This is the flip side of finding a file on Github and clicking on the Raw link.

+9
source
 raw.githubusercontent.com/username/repo-name/branch-name/path 

Replace username with the name of the user who created the repo.

Replace repo-name with the repo name.

Replace branch-name with the name of the branch.

Replace path with the file path.

To return to go to GitHub.com:

 GitHub.com/username/repo-name/directory-path/blob/branch-name/filename 
0
source

All Articles