Friedrich Ewald My Personal Website

Playing with git hooks

Git scm offers a very interesting technique, called hooks. A hook is basically a trigger which is fired after the specific event occurs. If you create a new git repository with git init the folder .git/hooks with a couple of sample shell scripts is created. I personally use a hook to automate the deployment process of this website. After a commit is made, I automatically run a jekyll build and then copy the newly created site to the server. My current post-commit script looks like the following, simple but effective:

#!/bin/bash
jekyll build
scp -r _site/* user@host:/home/user/html/
##Update 2015-12-11 I slightly changed the deploy script to only update changed files because I realized that the time to update the homepage will increase with every posting. For this reason I had to use rsync. Now the scripts looks as follows:
#!/bin/bash
jekyll build
rsync --update --progress -r _site/* user@host:/home/user/html/
The easiest way to synchronize over SSH is with a certificate.


About the author

is an experienced Software Engineer with a Master's degree in Computer Science. He started this website in late 2015, mostly as a digital business card. He is interested in Go, Python, Ruby, SQL- and NoSQL-databases, machine learning and AI and is experienced in building scalable, distributed systems and micro-services at multiple larger and smaller companies.