Git Checkout Using Partial Branch Name Matching

2020-07-13 07:07 (5 years ago)
Git Checkout Using Partial Branch Name Matching

How about this? zsh bash

CO() {
if [ ! "$1" ] ; then
echo 'usage: CO branch-name'
git branch
return
fi
branchname=$(git branch --format="%(refname:short)" | grep $1)
if [ ! "$branchname" ]; then
echo "branch name not found. $1"
echo "branch names:"
git brahcn
return
fi
git checkout $branchname
}
Please rate this article
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive