Last active
May 24, 2019 09:53
-
-
Save tommy-muehle/70d8fe9bf0c66de26478 to your computer and use it in GitHub Desktop.
Git hook to auto-merge hotfix branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
while read oldrev newrev refname | |
do | |
BRANCH=$(git rev-parse --symbolic --abbrev-ref $refname) | |
if [[ "$BRANCH" =~ ^hotfix/* ]]; then | |
echo " /===============================" | |
echo " | HOTFIX DETECTED ..." | |
GIT_WORK_TREE=/tmp git checkout master -f -q | |
GIT_WORK_TREE=/tmp git merge $BRANCH -q --comit -m "Merge $BRANCH" --no-ff | |
echo " | ... AND MERGED" | |
echo " \==============================" | |
exit 0; | |
else | |
exit 0; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where should this file be placed for git to pick up and execute?