cop
Check out a branch by a partial branch name. This function searches for branches containing the provided pattern and checks out the first match.
I name branches with a reference to a work item number, then use the work item number to checkout the right branch. For example, the branch might be called feature/12345-updated-invoice-structure and I can check it out with git cop 12345 or git cop invoice.
From Stack Overflow.
Usage:
git cop 12345
CLI Command
git config --global alias.cop "!f() { git branch -a | grep -m1 -e ${1}.*${2} | sed "s/remotes\/origin\///" | xargs git checkout; }; f"
.gitconfig Snippet
[alias]
cop = !f() { git branch -a | grep -m1 -e ${1}.*${2} | sed "s/remotes\/origin\///" | xargs git checkout; }; f