Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Make a git commit including the issue number in the message
# Add this code to your ~/.bashrc (Linux) or ~/.bash_profile (macOS)
# Given a branch named with the pattern `feature/123456-some-branch`,
# makes a commit with the message "refs #123456 whatever"
# if called like `gc 'whatever message you want'`
gc() {
if [ "$1" == "" ]
echo "You must provide a commit message."
issueNumber=$(git branch | grep \* | cut -d/ -f 2 | cut -d- -f 1)
git commit -m "refs #$issueNumber $@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.