Skip to content

Instantly share code, notes, and snippets.

@palashkulsh
Created June 27, 2018 08:04
Show Gist options
  • Save palashkulsh/e6721e65d76ba8dfc3dfeb828c9e4ea6 to your computer and use it in GitHub Desktop.
Save palashkulsh/e6721e65d76ba8dfc3dfeb828c9e4ea6 to your computer and use it in GitHub Desktop.
prepend the branch name in commit msg
put this file in .git/hooks/prepare-commit-msg file and run chmod 755 .git/hooks/prepare-commit-msg file . this prepends the branch name in the commit msg. it is useful when you have to mention jira id in every commit. then you can make a branch name with jira id in it and branch name would be prepended in every commit msg.
#!/bin/sh
BRANCH=`git branch | grep '^\*' | cut -b3-`
FILE=`cat "$1"`
echo "$BRANCH $FILE" > "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment