I have a git repo that has a docs directory where I keep markdown files that document things I’m working on (for example, I have one called setup_git_server.mdown). I push and pull the repository (and others) from my own webserver running gitolite.
What I want to happen is that whenever I push a commit to the server, it automatically converts the markdown files to HTML and copies them to a directory on the server where Apache can server them.
What’s the best way to do this?
You will want to setup a git hook on the server your repository is hosted. A hook will only run on the machine where it is installed. The hooks themselves are not part of the checked in code base. For example, any post commit hooks you have on your local machine will not be pushed or executed on the server. Other people who check our your code base will not get your hooks.
If you want the server to take an action when it receives a push, you should create a post-receive hook. The hook can be any executable. In your case, you may want to clone your repo to a temp directory, extract the markdown file, and publish it to your web server.
I’m not sure if it’s the same for gitolite, but in gitosis, the hooks directory is in the top level of each hosted repository. Place your post-receive hook in that directory.