Using git hook with Hexo on self-hosted server

Hexo supports github page by default, which is very nice. But when coming to use a local bare git repository is a bit tricky.

Here is the git hook script coming to rescue, {in target bare repo}/hooks/post-receive:

#!/usr/bin/env bash
git --work-tree=/home/$USER/{published repo} --git-dir=/home/$USER/{published repo}/.git pull

{published repo} is the working git repo that ideally also use for web server root path.

After _config.yml being properly set up, now I am able to streamline the deploying process without manuall pulling the published repository every single time.

$ hexo g -d