Skip to content

Instantly share code, notes, and snippets.

@dragon788
Forked from atenni/README.md
Last active March 24, 2024 07:57
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save dragon788/dadcc5d1d1258b5d0d56 to your computer and use it in GitHub Desktop.
Save dragon788/dadcc5d1d1258b5d0d56 to your computer and use it in GitHub Desktop.
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

(via: http://stackoverflow.com/a/14529686)

BitBucket "snippets" are essentially the same thing (can be cloned/files viewed raw).

Specific file downloads are available, but not a generic "return first file": https://bitbucket.org/!api/2.0/snippets/[bitbucket_user]/[snippet_id]/master/files/[file_name]

You can also shorten these really long URLs using the https://git.io service. If you want a custom vanity tag you can follow the directions in a blog post I have to relocate or use the PowerShell module I threw together to handle the fiddly bits for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment