Skip to content

Instantly share code, notes, and snippets.

@subfuzion
Last active April 20, 2024 09:22
Show Gist options
  • Save subfuzion/0d3f19c4f780a7d75ba2 to your computer and use it in GitHub Desktop.
Save subfuzion/0d3f19c4f780a7d75ba2 to your computer and use it in GitHub Desktop.
GitHub Wiki How-To

How do I clone a GitHub wiki?

Any GitHub wiki can be cloned by appending wiki.git to the repo url, so the clone url for the repo https://myorg/myrepo/ is: git@github.com:myorg/myrepo.wiki.git (for ssh) or https://github.com/my/myrepo.wiki.git (for https).

You make edits, and commit and push your changes, like any normal repo. This wiki repo is distinct from any clone of the project repo (the repo without wiki.get appended).

How do I add images to a wiki page?

You need to clone the wiki repo and edit it on your system.

Add images to an images directory (or subdirectory below it) in your wiki repo. For example: images/project-architecture/project-architecture-overview.png.

In your wiki page markup, embed an image link in the following format:

[[/images/path/to/image.ext|ALT TEXT]]

Note the leading / in the path. You don't need it if all your wiki docs and image files are located at the top level of the wiki (like when you use the online wiki editor), but if you are working with a clone of the wiki, then you can organize files in subdirectories; and in that case, absolute or relative path specifiers are critical so that the path to the image resolves correctly when editing a doc that is located in a different subdirectory.

Commit and push your changes.

Note

This is not the same as providing a link to an image that is part of your project repo (not the wiki repo). If you want to link to an image in your project repo, you will need a full URL that looks something like this:

[[https://github.com/username/repository/blob/master/img/octocat.png|alt=octocat]]

See references, below.

How do I add files to a wiki page?

You need to clone the wiki repo and edit it on your system.

Add files to the files directory (or subdirectory below it). For example: files/project-presentation.pdf`.

In your wiki page markup, add the file link in the following format:

[link text](files/path/to/file "ALT TEXT")

For example:

[Project Presentation](files/project-presentation.pdf "Project Presentation PDF")

Commit and push your changes.

See related references

@danieljwoods
Copy link

danieljwoods commented Feb 14, 2018

Thanks for this, very helpful.

A minor and important correction: In section "How do I clone a GitHub wiki?" .. change

git@github.com/myorg/myrepo.wiki.git
to
git@github.com:myorg/myrepo.wiki.git

They differ in the first '/' in the first line becomes a ':'

@ankitpateledu
Copy link

i tried git clone https://github.com/my/myrepo.wiki.git but it clones only wiki files not the project files.
How do i clone repo with project files as well as with wiki files?

@weishang
Copy link

Think of the project files and the wiki pages in separate repos. So I don't think it is possible.

@schroef
Copy link

schroef commented May 1, 2018

How do we edit our own wiki and add images, i dont want a folder in my repo containing images for the wiki part. If i look at some others they have a folder in the there Repo called '/raw/master/wiki/images/'

@weishang
Copy link

weishang commented May 2, 2018

  1. clone your wiki repo
  2. add images to the images folder
  3. reference the images with [[images/MY_IMAGE.PNG]] (no backslash or dot before images)
  4. commit and push
  5. check page

http://mikehadlow.blogspot.ca/2014/03/how-to-add-images-to-github-wiki.html

@ASPePeX
Copy link

ASPePeX commented May 7, 2018

@ankitpateledu I did not try this but you should be able to reference your wiki as a submodule of your main repo (or the other way round). But this means everyone cloning your repo would also clone the wiki.

@bwl21
Copy link

bwl21 commented May 8, 2018

How can i contribute to a wiki of a Project without being a collaborator. It seems that there is no pull request for the wiki repository.

@oscarrodar
Copy link

Nice 😄

@cyphunk
Copy link

cyphunk commented Aug 21, 2018

This no longer appears to work. I've tried changing the wiki from .md to .wiki extension. Either do not help. I've tried the following syntax as well:

[[images/myimage.jpg]]
[[/images/myimage.jpg]]
[[/raw/master/images/myimage.jpg]]
[[../raw/master/images/myimage.jpg]]
[[../../raw/master/images/myimage.jpg]]
[[blob/master/images/myimage.jpg]]
[[/blob/master/images/myimage.jpg]]
[[../blob/master/images/myimage.jpg]]
[[../../blob/master/images/myimage.jpg]]
[[Image:images/myimage.jpg]]
[[Image:/images/myimage.jpg]]
[[Image:/raw/master/images/myimage.jpg]]
[[Image:../raw/master/images/myimage.jpg]]
[[Image:../../raw/master/images/myimage.jpg]]
[[Image:blob/master/images/myimage.jpg]]
[[Image:/blob/master/images/myimage.jpg]]
[[Image:../blob/master/images/myimage.jpg]]
[[Image:../../blob/master/images/myimage.jpg]]

@cyphunk
Copy link

cyphunk commented Aug 21, 2018

Correction, it works. Here is the results that work for .md or .wiki. Example assumes you've created a images directory in the wiki's repository with a image named myimage.jpg:

.wiki:

[[images/myimage.jpg]]
[[/images/myimage.jpg]]

markdown !()[] syntax will not work

<img src="images/myimage.jpg">
img tag works but only with relative path

does not support figure and figcaption tags

.md:

[[images/myimage.jpg]]
[[/images/myimage.jpg]]

![](../../blob/master/images/myimage.jpg)
the markdown syntax works but not relative paths

<img src="images/myimage.jpg">
img tag works but only with relative path

<figure><img src="images/myimage.jpg"><figcaption>image caption</figcaption></figure>

@schroef
Copy link

schroef commented Sep 27, 2018

@cyphunk

I tried a couple your square bracket version, i they dont work for me.None of the relative work for me actually, only the absolute paths

This is also works, also a trick to prevent caching and updates working, add '?v_DATE' this helps prevent caching normally
!['Example Rig Presets'](https://raw.githubusercontent.com/wiki/schroef/extra-image-list/images/extra-image-list.jpg?v26-09-2018)

'Example Rig Presets'

@gwlucastrig
Copy link

I'd like to post a wiki page that explains some of the math behind my software. And, as such, it would include a fair number of equations. Is there a good way to do that? Using images seems a bit cumbersome. Perhaps I could use a PDF file as a wiki page? Is this kind of thing just too far out-of-scope for what the GitHub wiki system handles?

@anatolebeuzon
Copy link

Thanks @subfuzion! Though I believe it should be git@github.com:myorg/myrepo.wiki.git (: instead of /)

@JirkaDellOro
Copy link

JirkaDellOro commented Nov 4, 2018

I wonder if it's possible to access a Github-Wiki or images/files included there through Github-pages...?

@steklopod
Copy link

All my images are not showing:
https://github.com/steklopod/Tour-of-Scala/tree/master/src/main/resources/images
but it was!
Why GitHub has deleted them?

@subfuzion
Copy link
Author

@danieljwoods @oxlay - thanks for the catch. Fixed the ssh url.

@rafiki270
Copy link

@derekriemer
Copy link

Thanks @subfuzion! Though I believe it should be git@github.com:myorg/myrepo.wiki.git (: instead of /)

I'd like to post a wiki page that explains some of the math behind my software. And, as such, it would include a fair number of equations. Is there a good way to do that? Using images seems a bit cumbersome. Perhaps I could use a PDF file as a wiki page? Is this kind of thing just too far out-of-scope for what the GitHub wiki system handles?

Does it come with mathjax? try $$x_1+x_2+x_3$$ or something and see if it renders.

@felixvd
Copy link

felixvd commented Nov 26, 2019

I don't seem to have access rights to the wiki, although I can push to the main repository just fine. Anyone had any issues like this?

edit: You need to create the first wiki page before you can upload to it.

@shiyu99
Copy link

shiyu99 commented Sep 4, 2020

Hi, thank you for sharing your knowledge! One question though, the image part workred, but the pdf part didn't work for me:
[Initial Architect](resources/Initial Architect (Screen Scratch).pdf "Initial Architect (Screen Scratch)")
Is there a problem with my formatting

@dewcansam
Copy link

2nd paragraph - word 29 wiki.get appended should be wiki.git appended

@SiddharthShyniben
Copy link

@gwlucastrig you could try MathML

@askfriends
Copy link

I have forked a public repo which also have Wiki page, bit my forked repo doesnt have Wiki. So question is whats easy way to add/clone Wiki from that pulic repo to my forked repo?

@mikebeaton
Copy link

mikebeaton commented Feb 4, 2022

@askfriends:

  • Temporarily create a new Wiki on your fork of the main repo (just add a page to its Wiki in GitHub)
  • Add the cloning URL of this new wiki as a remote to a local clone of the original wiki
  • Force push the state of the upstream Wiki to the new Wiki

WARNING: Even if you have SSH set up and GitHub normally shows you the SSH URL for repos, it will still show you the HTTPS URL for Wiki repos, so remember to manually convert to the SSH URL format before you can push using SSH credentials.

@thegiftofgabes
Copy link

Is there any way I can clone the wiki of a project into vs codium in a way that I don't have to keep switching folders?

@michalradacz
Copy link

Hi, little stupid questionn: How to clone private wiki? I have private repo with private wiki, on web github.com all works done, but your workflow for Github desktop does not work. Any ideas? - and, YES, i am logged in and I am logged as me in Github desktop, all private repos works well, but no wikis.

@kosperera
Copy link

kosperera commented Jun 29, 2022

How I usually add images to wiki or any markdown is:

  1. Create a new issue in a repo
  2. Drag and drop the files from the local file system to the issue text area
    GitHub will upload the file to their CDN, then generates a markdown code snippet for you
  3. Copy the auto-generated code snippet, then paste where I wanna use
  4. Discard the new issue or save it
    Depends on what I wanna do with the list of images I uploaded.

@shadu120
Copy link

Unfortunately, this solution not work. When I tried to clone my private repo's. wiki , I got error mesages:

git clone git@github.com:abc-com/aaaaa.wiki.git
Cloning into 'aaaaa.wiki'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


 git clone https://github.com/abc-com/aaaaa.wiki.git
Cloning into 'aaaaa.wiki'...
remote: Repository not found.
fatal: repository 'https://github.com/abc-com/aaaaa.wiki.git/' not found

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