Skip to content

Instantly share code, notes, and snippets.

@blacktaxi blacktaxi/.gitconfig
Created Mar 23, 2017

Embed
What would you like to do?
git alias for tagging commits with Jira ticket IDs
[alias]
# commit with Jira ticket ID tag in commit message.
# current branch name has to start with a valid Jira ticket ID, in upper case.
c = "!f() { \
if [[ -z $1 ]]; \
then \
echo "Error: No commit message provided."; \
exit 1; \
else \
local ticketId=$(git rev-parse --abbrev-ref HEAD | grep -Eo "^[A-Z]+-[0-9]+"); \
if [[ -z $ticketId ]]; \
then git commit -m $1 ${@:2}; \
else git commit -m \"$ticketId $1\" ${@:2}; \
fi; \
fi; \
}; f"
$ git branch
* SF-123
master
$ git c "Shaving yaks"
[SF-123 fd1b2e6] SF-123 Shaving yaks
1 file changed, 1 insertion(+), 1 deletion(-)
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.