Blog now in Git

Here’s something that was on The List for a long time: adding this blog to a git-repository. Why did that take so long?

I wanted to have my own, personal git-server instead of GitHub to push stuff to, so I can have a post-hook do cool stuff like auto-deploy the website. That is possible with GitHub as well (if you pay for it), but I thought it would be ‘fun’ to play around with all this 🤓

My workflow used to be:

My new workflow:

My server then checks out the most recent commit, runs jekyll build and rsyncs the new items. Because that happens automatically it’s a lot less fault-sensitive.

You are now reading the first article published with git push 😇. Currently only works like this, but in the near future I’ll port as well.

My setup

I’ve installed both git and jekyll on my VPS and added a new user there (git). In the home-folder of git I’ve setup blank repositories for all my projects (like this site). On my local machine I created a new RSA-key specifically for the git user (not strictly necessary, but I was in an experimenting mood).

I then created a new repository for this blog locally, added all files and set the origin to the server. Done!




mkdir /tmp/${site}
rm -rf /tmp/${site}/*
git --work-tree=/tmp/${site} --git-dir=/home/git/${site} checkout -f
cd /tmp/${site}
jekyll build
rsync -av _site/ /var/www/${site}/public_html/ --itemize-changes