Skip to content

Instantly share code, notes, and snippets.

@nkcmr
Created November 30, 2022 13:58
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 nkcmr/df54faabc6d32e1982c509458b19079d to your computer and use it in GitHub Desktop.
Save nkcmr/df54faabc6d32e1982c509458b19079d to your computer and use it in GitHub Desktop.
#!/bin/bash
# should rename it just "git-newbranch" and put it in your path somewhere.
# once that is done it should be invokable as "git newbranch JIRA-123"
set -euo pipefail
JIRA_NUMBER="${1:-}"
if ! [[ "$JIRA_NUMBER" =~ ^[A-Z]{2,}-[0-9]+$ ]] ; then
echo "$(basename $0): error: invalid Jira number"
exit 1
fi
USERNAME="${GIT_NEWBRANCH_USER:-$USER}"
git checkout -b "$USERNAME/$JIRA_NUMBER/$(date +%s)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment