Github gist editing without changing URL

后端 未结 6 1597
轻奢々
轻奢々 2021-01-31 16:12

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



        
相关标签:
6条回答
  • 2021-01-31 16:40

    The other methods didn't work, so I'm using rawgit.com:

    https://rawgit.com/<user>/<id>/raw/<file>
    
    0 讨论(0)
  • 2021-01-31 16:50

    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

    0 讨论(0)
  • 2021-01-31 16:53

    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

    0 讨论(0)
  • 2021-01-31 16:53

    Just add /raw to the end of your gist url.

    https://gist.github.com/--user--/--id--/raw
    

    This links to the latest revision of that file.

    After updating the gist file, changes are reflected after a minute or two.

    0 讨论(0)
  • 2021-01-31 16:56

    It is also possible to remove your username from the url, if you want.

    Take the url from the accepted answer above:

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

    remove <USER_NAME> and move raw in front of <GIST_ID>, where the username was:

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

    But it doesn't work with RawGit.

    0 讨论(0)
  • 2021-01-31 17:00

    You can't change the content without submitting it (saving it) and that gives you a new URL.

    If you want a link to something you will be constantly changing and have the URL always be the same, put it in a repo and save changes by committing it.

    You'll end up with something like:

    https://raw.github.com/UserName/Repository/master/script.js

    0 讨论(0)
提交回复
热议问题