< back

Just Some Git Magic

2021/05/16

This might be trivial to some, but today I set up a special piece of Git magic for this website.

The Magic

Using a post-receive Git hook, I can have this website update automatically whenever I push a commit to its Git repository on this server.

#!/bin/sh

DEPLOY_DIR=/path/to/www/htdocs
REPO_DIR=/path/to/git/repo

git --work-tree=$DEPLOY_DIR --git-dir=$REPO_DIR checkout -f master
make -C $DEPLOY_DIR

Beautiful, isn't it? With just a few lines of code, I've replicated the main function of something like GitHub Pages.

Remember KISS: Keep it simple, sisters!