Skip to content

Instantly share code, notes, and snippets.

@justinbarry
Created January 13, 2022 00:24
Show Gist options
  • Save justinbarry/c55b8aee285644426c68d2e634d1a980 to your computer and use it in GitHub Desktop.
Save justinbarry/c55b8aee285644426c68d2e634d1a980 to your computer and use it in GitHub Desktop.
#!/bin/bash
((!$#)) && echo No issue number provided, command ignored! && exit 1;
TITLE=$(gh issue view $1 --json title | jq --raw-output '.title' )
ESCAPED_TITLE=$(echo "GH-$1-${TITLE// /-}" | tr -cd '[:alnum:][\-]' | cut -c1-100);
if [ `git branch --list $ESCAPED_TITLE` ]; then
git checkout $ESCAPED_TITLE;
else
git checkout dev;
git pull origin --rebase;
git checkout -b $ESCAPED_TITLE;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment