54

I created a gist with two files, the raw version of which I would like to use as a reference for an application which will query their contents. These contents will be updated on GitHub.

I found however that the URL of the file changes with each version of the gist. Is there a permalink which would point to the latest version of a file in a gist?

WoJ
  • 27,165
  • 48
  • 180
  • 345

1 Answers1

94

Raw gist URLs follow the pattern below:

https://gist.githubusercontent.com/[gist username]/[gist ID]/raw/[gist commit ID]/[file name]

To view the latest version, simply remove the [gist commit ID] part:

https://gist.githubusercontent.com/[gist username]/[gist ID]/raw/[file name]

e.g.

https://gist.githubusercontent.com/mwek/9962f97f3bde157fd5dbd2b5dd0ec3ca/raw/user.js

Keep in mind that the endpoint is cached, so your updates may be visible with a slight delay.

mwek
  • 1,154
  • 9
  • 4
  • 4
    Do you know how long it will take for the cached version to be updated with the newest changes? – Rubatharisan Thirumathyam Apr 05 '18 at 09:43
  • 14
    FWIW it looks like you can cache-bust by attaching a query string to the url, e.g. `https://gist.githubusercontent.com/mwek/9962f97f3bde157fd5dbd2b5dd0ec3ca/raw/user.js?cachebust=dkjflskjfldkf` – nietaki Apr 18 '18 at 21:49
  • The file will (probably) be served with incorrect MIME type because of..human laziness. – vsync Jul 05 '18 at 14:34
  • 5
    Actually it seems that removing the end part also is needed, otherwise you might get old version of the file for some reason.. So it's: https://gist.githubusercontent.com/[gist username]/[gist ID]/raw/ – J-ho Mar 18 '20 at 15:46
  • What user permission is required to do this? – Justin Thomas Dec 18 '20 at 21:29
  • @JustinThomas No permissions. It's public. – Mike Mar 05 '21 at 15:32