Skip to content

Instantly share code, notes, and snippets.

@tommy-muehle
Last active May 24, 2019 09:53
Show Gist options
  • Save tommy-muehle/70d8fe9bf0c66de26478 to your computer and use it in GitHub Desktop.
Save tommy-muehle/70d8fe9bf0c66de26478 to your computer and use it in GitHub Desktop.
Git hook to auto-merge hotfix branches
#!/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
@SanthoshBabuMR
Copy link

where should this file be placed for git to pick up and execute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment