Skip to content

Instantly share code, notes, and snippets.

@coffman21
Created March 20, 2019 10:17
Show Gist options
  • Save coffman21/2bed0d1a6b0e5e5f0f0f4f2e075eb256 to your computer and use it in GitHub Desktop.
Save coffman21/2bed0d1a6b0e5e5f0f0f4f2e075eb256 to your computer and use it in GitHub Desktop.
Git hook which adds branch name to commit
#!/bin/sh
BRANCH=$(git symbolic-ref --short HEAD)
COMMIT_MSG=$(cat $1)
if [[ $BRANCH == CPP-* ]] ;
then
echo "$BRANCH $COMMIT_MSG" > $1
exit 0
else
echo "$COMMIT_MSG" > $1
exit 0
fi
exit -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment