こんな感じでどうでしょう。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
}
コメント