Skip to content

Instantly share code, notes, and snippets.

@sanmai
Forked from bartoszmajsak/prepare-commit-msg.sh
Last active December 23, 2015 08:28
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 sanmai/6607597 to your computer and use it in GitHub Desktop.
Save sanmai/6607597 to your computer and use it in GitHub Desktop.
Leaves as is any commit message other than for new commits.
#!/bin/bash
if [[ "$2" == "message" || -z "$2" ]]; then
BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *')
if [[ -n "$BRANCH_NAME" && "$BRANCH_NAME" != "master" ]]; then
echo "$BRANCH_NAME: $2 $(cat $1)" > $1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment