I have followed this excellent write up http://toroid.org/ams/git-website-howto to deploy code to my server using Git's post-hooks strategy.
I have a post-update file that looks like this:
GIT_WORK_TREE=/home/rajat/webapps/<project name> git checkout -f
Everytime I push code to master branch, it gets auto deployed. What I want to do now is to make this support multiple branches, so that:
For this, the post-update hook needs to understand which branch got updated. Is this possible ?
It is possible to write a post-update hook which detect the branch name.
See for inspiration:
git post-receive
hook to deal with a specific branch" As an example (all those hooks are based on git rev-parse
):
#!/bin/bash
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
# Do something
fi
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With