Skip to content
willcodeforfoo edited this page Sep 12, 2010 · 7 revisions

Cloning your wiki

What makes git-wiki so cool is because it is backed by a git store, you can clone your wiki just like you could any other git repository. I’ve always wanted a wiki that I could a.) pull offline when I didn’t have access to the Internets and b.) edit (perhaps in bulk) in my favorite text editor. git-wiki allows both.

Say you have an iMac at home, and a MacBook Air (hey, this is pretend world and you have all the cash you want) you take with you everywhere. git-wiki created your wiki for you at iMac:~/wiki but you’d really like to have your data available on your MacBook for your flight to LAS. Simple, just “clone” your wiki git repository on your MacBook (note, you’ll need to have SSH enabled on your iMac, Apple calls it “Remote Login” in the “Sharing” System Preferences panel):

MacBook:~$ git clone user@iMac:~/wiki
Initialized empty Git repository in /Users/kmarsh/wiki/.git/
remote: Generating pack...
remote: Done counting 270 objects.
remote: Deltifying 270 objects...
remote:  100% (270/270) done
Indexing 270 objects...
remote: Total 270 (delta 8), reused 0 (delta 0)
 100% (270/270) done
Resolving 8 deltas...
 100% (8/8) done

Guess what? You now have a folder in your home directory on your MacBook called wiki. It has, you guessed it, the complete copy of your wiki from your iMac. Even better? It has all the revisions from your iMac as well. Editing in <textarea>s is so 1997. Why don’t you open up your wiki and edit it in TextMate?

MacBook:~$ cd wiki
MacBook:~$ mate .

Hee-haw! Use your editor to make all the changes to your wiki you want. You’re on the plane, you’re editing your wiki! Wheee! Make sure you commit periodically so you can git diff later on. Remember, your repository is on your machine, but that doesn’t mean you don’t have to commit. (As a former SVN user, this was tricky for me at first):

MacBook:~$ git commit -a

What about when you get to your hotel, check out the free wi-fi, and get online? Push your changes back to your iMac! After all, you’ll still want all those edits even if you lose your shiny new MacBook in a poker match:

MacBook:~$ git push
updating 'refs/heads/master'
  from 2fb07c3038fb95b10163e98dd6faf12f73cfcd6e
  to   1b4e1360b7fa8d6b35116698206cf93a9fec4ff4
 Also local refs/remotes/origin/master
Generating pack...
Done counting 3 objects.
Deltifying 3 objects...
 100% (3/3) done
Writing 3 objects...
 100% (3/3) done
Total 3 (delta 0), reused 0 (delta 0)
refs/heads/master: 2fb07... -> 1b4e1.....
Clone this wiki locally