Did you know you can upload images (and other static files) to a gist simply because it’s a Git repository?
Instructions
First you need to make sure you’re logged in to your GitHub account.
- Create or find a gist that you own.
-
Clone your gist (replace
<hash>
with your gist’s hash):# with ssh git clone git@gist.github.com:<hash>.git mygist # or with https git clone https://gist.github.com/<hash>.git mygist
-
Change to your gist’s directory:
cd mygist
-
Add and commit the image:
git add image.jpg git commit -m "Add image to gist"
-
Update remote:
git push origin master
And voilà you can view the image in your gist:
open https://gist.github.com/<username>/<hash>
If you inspect the Raw file, you’ll get something like the following:
https://gist.githubusercontent.com/<username>/<gist-sha>/raw/<commit-sha>/image.jpg
One disadvantage of gist is it doesn’t support directories. This means all files live in the root folder of the repository.
Example
See gist: