How To Add Images To A GitHub Wiki
Every GitHub repository comes with its own wiki. This is a great place to put the documentation for your project. What isn’t clear from the wiki documentation is how to add images to your wiki. Here’s my step-by-step guide. I’m going to add a logo to the main page of my WikiDemo repository’s wiki:
First clone the wiki. You grab the clone URL from the button at the top of the wiki page.
$ git clone email@example.com:mikehadlow/WikiDemo.wiki.git Cloning into 'WikiDemo.wiki'... Enter passphrase for key '/home/mike.hadlow/.ssh/id_rsa': remote: Counting objects: 6, done. remote: Compressing objects: 100% (3/3), done. remote: Total 6 (delta 0), reused 0 (delta 0) Receiving objects: 100% (6/6), done.
Create a new directory called ‘images’ (it doesn’t matter what you call it, this is just a convention I use):
$ mkdir images
Then copy your picture(s) into the images directory (I’ve copied my logo_design.png file to my images directory).
$ ls -l -rwxr-xr-x 1 mike.hadlow Domain Users 12971 Sep 5 2013 logo_design.png
Commit your changes and push back to GitHub:
$ git add -A $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: images/logo_design.png # $ git commit -m "Added logo_design.png" [master 23a1b4a] Added logo_design.png 1 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 images/logo_design.png $ git push Enter passphrase for key '/home/mike.hadlow/.ssh/id_rsa': Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (4/4), 9.05 KiB, done. Total 4 (delta 0), reused 0 (delta 0) To firstname.lastname@example.org:mikehadlow/WikiDemo.wiki.git 333a516..23a1b4a master -> master
Now we can put a link to our image in ‘Main Page’:
Save and there’s your image for all to see:
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)