Skip to content

Instantly share code, notes, and snippets.

@dbilovd
Last active March 24, 2017 09:09
Show Gist options
  • Save dbilovd/bef9e310bfb6bc94ae00344516cdd0cf to your computer and use it in GitHub Desktop.
Save dbilovd/bef9e310bfb6bc94ae00344516cdd0cf to your computer and use it in GitHub Desktop.
Git Hooks
#!/bin/sh
#
#
#
# To enable this hook, rename this file to "post-commit".
echo "Running Post-Commit hook: Push immediately to master after commits"
# Get current branch
branch=$(git rev-parse --abbrev-ref HEAD)
# Merge into and push master
if [ $branch == "dev" ]; then
git push origin dev
git checkout master
git merge dev
elif [ $branch == "master" ]; then
echo "Already in master branch"
fi
git pull origin master
git push origin master
git checkout dev
echo "Completed: pushing after commit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment