Skip to content

Instantly share code, notes, and snippets.

@raksa
Created September 25, 2018 09:47
Show Gist options
  • Save raksa/5f9c045574a5e3b6637d0bad63f3174f to your computer and use it in GitHub Desktop.
Save raksa/5f9c045574a5e3b6637d0bad63f3174f to your computer and use it in GitHub Desktop.
for git (bare) hook post receive
#!/bin/bash
function do_something () {
echo "do something"
}
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "options:"
echo "-h, --help show brief help"
echo "-ng execute no git"
exit 0
;;
-ng)
do_something
exit 0
;;
esac
done
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
do_something
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment