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.

@vijeth-aradhya
Copy link

vijeth-aradhya commented Mar 11, 2017

Thanks a lot! 😄

@RusticFlare
Copy link

RusticFlare commented May 8, 2017

Thank you 👍

@RobertoPrevato
Copy link

RobertoPrevato commented May 10, 2017

Thanks! 👍

@kruncher
Copy link

kruncher commented May 10, 2017

Thanks! 👍

@vishnu-kyatannawar
Copy link

vishnu-kyatannawar commented Jun 24, 2017

Thanks #

@ugumerie
Copy link

ugumerie commented Jul 3, 2017

How did you add the image? Because after the cloning, I manually added the image to the repo folder created after the clone. When I try to add the image I would get an error saying fatal: pathspec 'CustomCheckbox.JPG' did not match any files Am new to this. Thank you

@ibrahim5253
Copy link

ibrahim5253 commented Jul 10, 2017

It reorders the images in my case. But thanks anyway.

@yh2n
Copy link

yh2n commented Jul 18, 2017

Thanks!
@ugumerie: Before adding the image to your repo, drag and drop the picture into the folder you cloned.

@Aneesh540
Copy link

Aneesh540 commented Jul 22, 2017

👍 😃

@aabenitez
Copy link

aabenitez commented Aug 25, 2017

Excelent! It works..

@IskanderIV
Copy link

IskanderIV commented Oct 3, 2017

Thks a LOT!!!

@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

SHADOWELITE7 commented May 8, 2018

thanks, this really helps me alot

@companje
Copy link

companje commented Jun 20, 2018

thanks!

@angusgrant
Copy link

angusgrant commented Aug 28, 2018

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

xurizaemon commented Nov 6, 2018

@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

philshem commented May 14, 2019

@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

aslafy-z commented Mar 20, 2020

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

vaimalaviya1233 commented Dec 31, 2020

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

vaimalaviya1233 commented Dec 31, 2020

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

blurymind commented May 28, 2021

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