2012-01-07

Making a github project readable as a web page

It is no secret, I love github (and git).

Today I updated my knowledge on javascript.

I started to wrote a game, the slim volleyball game to be exact (see reddit).

So I pushed the thing on github.
However, the files were not served as being part of a web page.

Fortunately, github implements a service called github pages which allows any github user to share a web page about something using the user's username.

This service also allows one to add a branch called 'gh-pages' (refs/heads/gh-pages to be exact I believe) to git repository to serve its content on the web. The content of the branch 'gh-pages' for projectX of userA is served as a web page at http://userA.github.com/projectX.


Initially, the only reference is usually 'master' (along with its remote twin).

seb@godzilla$ git branch -a
* master
  remotes/origin/master

To serve all the content of the branch 'refs/heads/master' on github pages, a symbolic reference called 'refs/heads/gh-pages' must be created.


seb@godzilla$ git symbolic-ref "refs/heads/gh-pages" "refs/heads/master"

Then you can list the branches.

seb@godzilla$ git branch -a
  gh-pages -> master
* master
  remotes/origin/master

The next thing you need to do is to push the references.

seb@godzilla$ git push --mirror

The gh-pages reference is now on the remote site too.

seb@godzilla$ git branch -a
  gh-pages -> master
* master
  remotes/origin/gh-pages
  remotes/origin/master

While the the project is available on github as usual, the same content is served on the web too !

No comments:

There was an error in this gadget