Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

How to add an image to a gist

  1. Create or find a gist that you own.

  2. Clone your gist (replace <hash> with your gist's hash):

    # with ssh
    git clone git@gist.github.com:<hash>.git mygist
    
    # with https
    git clone https://gist.github.com/<hash>.git mygist
  3. Change to your gist’s directory:

    cd mygist
  4. Add and commit the image:

    git add tulip.jpg
    git commit -m "Add tulip to gist"
  5. Update remote:

    git push origin master

See blog post.

@yomexzo
Copy link

yomexzo commented Oct 23, 2017

Thank you! 😄

@iammart
Copy link

iammart commented Jan 5, 2018

This was really useful, thanks for sharing 👍

@xu-song
Copy link

xu-song commented Jan 20, 2018

gist does not support directories. ... not happy

@cbcunc
Copy link

cbcunc commented Mar 14, 2018

Superb.

@821jieun
Copy link

821jieun commented Apr 2, 2018

thank you :)

@SHADOWELITE7
Copy link

thanks, this really helps me alot

@companje
Copy link

thanks!

@angusgrant
Copy link

Hi can some one advise how I clone the following gist repo. https://gist.github.com/angusgrant/8599b573d600539f192d9c5709bc1e6e.
I try this git clone git@gist.github.com:8599b573d600539f192d9c5709bc1e6e.git mygist but I get error message:
git@gist.github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please advise I'm new to github/gist. thanks.

@xurizaemon
Copy link

@angusgrant Github's SSH setup docs are at https://help.github.com/articles/connecting-to-github-with-ssh/ - once you have SSH set up, gist and github should both work the same.

@GUIEEN
Copy link

GUIEEN commented Jan 10, 2019

Thanks :)

@philshem
Copy link

@xurizaemon @angusgrant

@angusgrant Github's SSH setup docs are at https://help.github.com/articles/connecting-to-github-with-ssh/ - once you have SSH set up, gist and github should both work the same.

FWIW, for me, github was always working fine, but I had a similar error message when I did my first push. Because I have TFA with my login, I had to use my username and token (not password). Once I did that one time, my ssh key was correctly used subsequent times.

https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line

@aslafy-z
Copy link

I found another way without the need of a Git client:

  • Save your gist
  • Add your image to a draft comment
  • Copy the resulting markdown
  • Edit your gist and add a markdown file
  • Paste the image as markdown inside

@vaimalaviya1233
Copy link

i have a question instead of picture can i add .zip file which is less than 5-10MB?

@xurizaemon
Copy link

xurizaemon commented Dec 31, 2020

@vaimalaviya1233 You should try it on a gist of your own and find out! If that doesn't work, you can download a gist as a zip file - so you might use that to share a set of files, with some limitations (eg if you don't need a directory structure in the zip). Good luck!

@vaimalaviya1233
Copy link

You should try it on a gist of your own and find out! If that doesn't work, you can download a gist as a zip file - so you might use that to share a set of files, with some limitations (eg if you don't need a directory structure in the zip). Good luck!

Thaks

@blurymind
Copy link

can we do this without file system access and by using the REST api instead? I need to be able to do it from a mobile pwa

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