Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mroderick/1afdd71aa69f6b29601d335751a1a9be to your computer and use it in GitHub Desktop.
Save mroderick/1afdd71aa69f6b29601d335751a1a9be to your computer and use it in GitHub Desktop.
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.

  2. Clone your gist:

    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone [email protected]:<hash>.git     # or with ssh
  3. Add your image to your gist's repository:

    git add your-image.jpg
  4. Commit the image:

    git commit -m "Add image"
  5. Update gist:

    git push origin master
@o-az
Copy link

o-az commented Nov 26, 2023

ansi-color-codes

@src-ry
Copy link

src-ry commented Jan 9, 2024

download

@shalva97
Copy link

image

@CodeByAidan
Copy link

If you get an error saying:

error: src refspec master does not match any
error: failed to push some refs to 'https://gist.github.com/<hash>.git'

Since your repository has a branch named "main", you should push your changes to that branch instead of "master". To push to the "main" branch, use the following command:

git push origin main

This command will push the changes in your local "main" branch to the remote repository.

@moshiurH
Copy link

^ Agreed, change from git push origin master to git push origin main.

@sullemanhossam
Copy link

sullemanhossam commented Jun 13, 2024

@sullemanhossam
Copy link

@codebydant
Copy link

The command with ssh is:

git clone [email protected]:HASH.git

@desrod
Copy link

desrod commented Jul 4, 2025

I just came here to mention that this no longer works.

You can clone the gist, add the image, push the image back to the gist, but then it overwrites the gist with just the image, and pushes the .md file as an unpreviewable attachment, which can only be viewed in 'Raw' mode.

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