Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nbkhope
Created December 6, 2017 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbkhope/c3f18a617ba039a8bfb1c10f09650e20 to your computer and use it in GitHub Desktop.
Save nbkhope/c3f18a617ba039a8bfb1c10f09650e20 to your computer and use it in GitHub Desktop.
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" == "" ]
then
echo "You must provide a commit message."
return
fi
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