Exploring Git: Customizing Commit Messages

Jake Henningsgaard
Dec 21, 2016 · 3 min read

Commit Message Convention

[JCH-296] - Fixed the 404 error for the Document download linkWhy: When viewing a pdf document in a users profile the document will preview but the download link is displays a 404 error. The link to the database was broken and needed updating.How:  
* Created variable to store static database path
* UserID & document name is appended to database path variable to retrieve document
Side Effects: This a static fix, may need to retrieve the database location dynamically to support future database changes/migrations.

Create a Template

Side Effects:
template = ~/.git-commit-message

Insert Issue Name & Number

# Ignore branches with specific names
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
# Get the name of the current branch
BRANCH_NAME=$(git symbolic-ref --short HEAD)
# Check if current branch should be ignored
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
BRANCH_IN_COMMIT=$(grep -c "\[$BRANCH_NAME\]" $1)
# Add branch name to commit messages
if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
sed -i.bak -e "1s/^/[$BRANCH_NAME] - /" $1



Jake Henningsgaard

Written by

Currently residing in Washington, DC. I most often work on big data type projects. I also spend a lot of time working with blockchain technologies.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade