Github编辑而不更改URL

Doo*_*nob 30 javascript url edit github

我在script标签中有一些javascript代码的要点,如下所示:

<script src="https://raw.github.com/gist/b25dff23c2c4b4bd425a/f157aa95163311c4b58febb06b49ffd16419f642/images.js"></script>
Run Code Online (Sandbox Code Playgroud)

我需要继续在github上编辑JS文件.但是,当您编辑要点时,它会更改要点的URL.如何保留相同的URL?

小智 47

Gist更改了此文件模式的路径:

https://gist.github.com/<USER_NAME>/<GIST_ID>/raw/<GIST_REVISION_ID>/<GIST_FILE_NAME>
Run Code Online (Sandbox Code Playgroud)

你会注意到现在最热门的答案'链接是404'.

只需应用这种新模式并vo!

https://gist.github.com/<USER_NAME>/<GIST_ID>/raw/<GIST_FILE_NAME>
Run Code Online (Sandbox Code Playgroud)

例如:

https://gist.githubusercontent.com/wesbos/cd16b8b1815825f111a2/raw/lol.js

  • 不要因为这里的示例链接导致404而被推迟; 那是因为marclundgren移动/删除/重命名了他的要点,而不是因为模式不起作用. (2认同)
  • 起初我认为这个答案不起作用。经过一点等待/实验后,Github 似乎对这种 Gist URL 进行了一些内部缓存。即使强制进行无缓存刷新,更改也需要 2-3 分钟才能反映在我的浏览器中。 (2认同)

xtr*_*ist 17

在gist的情况下,
https://raw.github.com/gist/[gist_id]OR
https://gist.github.com/[user_name]/[gist_id]/raw(更可能是唯一的URI.)
从gist返回第一个文件.

对于包含多个文件的要点,请访问https://raw.github.com/gist/[gist_id]/[file_name]

即使您更改文件名,网址也会起作用.

例如https://raw.github.com/gist/4636655 https://raw.github.com/gist/4636655/imdb-getglue.js


spe*_*.sm 9

只需添加/raw到您的要点网址的末尾.

https://gist.github.com/--user--/--id--/raw
Run Code Online (Sandbox Code Playgroud)

这链接到该文件的最新版本.

更新gist文件后,更改会在一两分钟后反映出来.