How do I get the raw version of a gist from github?

你说的曾经没有我的故事 提交于 2019-11-30 11:26:03

问题


I need to load a shell script from a raw gist but I can't find a way to get raw URL.

curl -L address-to-raw-gist.sh | bash

回答1:


And yet there is, look for the raw button (on the top-right of the source code).

The raw URL should look like this:

https://gist.githubusercontent.com/{user}/{gist_hash}/raw/{commit_hash}/{file}

Note: it is possible to get the latest version by omitting the {commit_hash} part, as shown below:

https://gist.githubusercontent.com/{user}/{gist_hash}/raw/{file}



回答2:


February 2014: the raw url just changed.
See "Gist raw file URI change":

The raw host for all Gist files is changing immediately.
This change was made to further isolate user content from trusted GitHub applications.

The new host is

 https://gist.githubusercontent.com. 

Existing URIs will redirect to the new host.

Before it was https://gist.github.com/<username>/<gist-id>/raw/...

Now it is https://gist.githubusercontent.com/<username>/<gist-id>/raw/...

For instance:

https://gist.githubusercontent.com/VonC/9184693/raw/30d74d258442c7c65512eafab474568dd706c430/testNewGist

KrisWebDev adds in the comments:

If you want the last version of a Gist document, just remove the <commit>/ from URL

https://gist.githubusercontent.com/VonC/9184693/raw/testNewGist




回答3:


Gitlab snippets provide short concise urls, are easy to create and goes well with the command line.

Sample example: Enable bash completion by patching /etc/bash.bashrc

sudo su -
(curl -s https://gitlab.com/snippets/21846/raw && echo) | patch -s /etc/bash.bashrc


来源:https://stackoverflow.com/questions/16589511/how-do-i-get-the-raw-version-of-a-gist-from-github

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!