Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github gist editing without changing URL

I have a gist with some javascript code in a script tag, like so:

<script src="https://raw.github.com/gist/b25dff23c2c4b4bd425a/f157aa95163311c4b58febb06b49ffd16419f642/images.js"></script>

And I will need to keep editing the JS file on github. However, when you edit a gist it changes the URL of the gist. How do I keep the same URL?

like image 946
tckmn Avatar asked Sep 20 '12 23:09

tckmn


People also ask

Can you edit a GIST after creating?

We can edit, delete, unsubscribe, star, embed, copy, share, and download a raw copy or zipped copy of a gist. We also can share a gist in multiple ways. You can opt to embed the gist into a website, copy a shareable link to send, clone (or copy) the gist via the git command to a local repository or via SSH.

Can I share secret gist?

Secret gists are not searchable and do not show up in Discover. They can only be used for your own purposes, as you cannot share them. If you want to create a public gist, make sure this option is deselected. Public gists are searchable, and they show up in Discover where people can browse newly appearing gists.

How do I change my gist from secret?

You can still convert a secret gist to a public gist by first selecting "Edit" -> "Make Public".


2 Answers

Gist changed the path to this file pattern:

https://gist.github.com/<USER_NAME>/<GIST_ID>/raw/<GIST_REVISION_ID>/<GIST_FILE_NAME>

You will notice that now the top answers' links are 404'ing.

Simply apply this new pattern and voilà!

https://gist.github.com/<USER_NAME>/<GIST_ID>/raw/<GIST_FILE_NAME>

For instance:

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

like image 91
marclundgren Avatar answered Oct 18 '22 03:10

marclundgren


In case of gist,
https://raw.github.com/gist/[gist_id] OR
https://gist.github.com/[user_name]/[gist_id]/raw(which is more likely to be an unique URI.)
returns first file from the gist.

For gist with multiple files, https://raw.github.com/gist/[gist_id]/[file_name]

The url works even when you change the filename.

e.g. https://raw.github.com/gist/4636655 https://raw.github.com/gist/4636655/imdb-getglue.js

like image 18
3 revs, 2 users 80% Avatar answered Oct 18 '22 05:10

3 revs, 2 users 80%