The intended audience for this post is rather specific: Game-Off, Game On, Global Game Jam and other game jam particpants. Actually, anyone interested in using GitHub to host both their games’ source code and the playable version may be interested.
If you have a static-ish game (HTML5, JavaScript, Flash, Unity, etc) with no serverside dependncies (databases, scoreboards, multiplayer, etc) then you can leverage GitHub Pages for free, fast, and reliable hosting.
Prerequisites
If you’re going to follow along with this micro tutorial, I’m assuming the following:
- You have installed Git
- You have a GitHub account; (you can sign up for a free account)
The simple example I have shows basic command line interaction. If you’re not comfortable on the command line, you can can also follow along with GitHub’s Mac or Windows clients.
Level 1: Forking
I’m not going to creating a game from scratch. Instead, I’m just going to fork the game Coil.
Let’s begin with forking that repository now.
Level 2: Cloning
Next, clone the repository that you’ve just forked (replace leereilly with your username obviously):
$ git clone https://github.com/leereilly/Coil.git Cloning into 'Coil'... remote: Counting objects: 37, done. remote: Compressing objects: 100% (26/26), done. remote: Total 37 (delta 11), reused 35 (delta 9) Unpacking objects: 100% (37/37), done.
Level 3: Playing
If you open the index.html file you should be able to play the game locally.
$ cd Coil/ $ open index.html
Level 4: Pushing
To host the game on GitHub you’ll need to create a branch called gh-pages.
$ git co -b gh-pages Switched to a new branch 'gh-pages' $ git push origin gh-pages Total 0 (delta 0), reused 0 (delta 0) To https://github.com/leereilly/Coil.git * [new branch] gh-pages -> gh-pages
Within a few minutes your game will be available at http://leereilly.github.com/Coil. Again, replace leereilly with your username.
Level 5: Custom Domain Names
You can also set up custom domain names. The CNAME file in my leereilly/leereilly.github.com repository ensures that that leereilly.github.com/Coil redirects to leereilly.net/Coil.
Games Hosted on GitHub
Here are a couple of random #ggo12 games that are using GitHub for version control and hosting: