Migrating a GitHub Wiki

Today I needed to migrate a GitHub wiki from one repo to another. Looking through the GitHub docs didn’t help that much. Lot’s of things about transferring the whole repo to someone else, but not just the wiki part.

In the end it turned out to be actually pretty easy, but there are two key things to understand before you get that Aha! moment.

The first thing to understand is that a GitHub wiki is actually a separate git repo. If your GitHub repo is at https://github.com/malcolmgroves/foobar.git then your wiki will be in an entirely separate repo at https://github.com/malcolmgroves/foobar.wiki.git.

The second thing to understand is that your wiki repo doesn’t exist until at least one page has been created. If you try and reference it when it is empty, git will complain that there is no such repo.

Once I realised these two things, then the path forward was pretty easy.

In my case, the destination wiki was empty, so I could just do the following:

  1. Clone my source wiki repo:
git clone https://github.com/malcolmgroves/foobar.wiki
  1. Create a dummy page in the destination wiki, to ensure the repo is created
  2. Add the destination wiki repo as a remote in my cloned repo
git remote add dest https://github.com/somebodyelse/foobardest.wiki.git
  1. Push the wiki to the new remote. Now you need to be careful with this one. As I mentioned, in my case the destination wiki was empty, so I could force the push. However, if there are already wiki pages in the destination, doing this will overwrite them. Instead you’ll want to pull those pages down before pushing.
git push dest --force

That’s it. Remarkably easy once you understand the how GitHub have implemented wikis.

Leave a Comment

Scroll to Top