Skip to content

Instantly share code, notes, and snippets.

@nad2000
Created June 13, 2017 00:20
Show Gist options
  • Save nad2000/180403819bbdb08d77b1c604f68ace4b to your computer and use it in GitHub Desktop.
Save nad2000/180403819bbdb08d77b1c604f68ace4b to your computer and use it in GitHub Desktop.
git post update hook that switches over to the pushed branch, updates the working directory and restarts the docker. It should be copied to .git/hooks/post-update
#!/bin/sh
## post-update hook recieves a list of all updated refs
for r in "$@"; do
case $r in
refs/heads/*) git --work-tree=$HOME --git-dir=$HOME/repo.git checkout -f $(git rev-parse --symbolic --abbrev-ref $r)
esac
done
cd $HOME
docker-compose restart
docker-compose logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment