---
slug: "git-checkout-contains"
title: "Git Checkout Using Partial Branch Name Matching"
description: "Pitfalls when running a local server with `php -S` on macOS Big Sur or later, and how to terminate SSL with a separate proxy."
url: "https://www.ytyng.com/en/blog/git-checkout-contains"
publish_date: "2020-07-13T07:07:48Z"
created: "2020-07-13T07:07:48Z"
updated: "2026-05-11T13:21:48.430Z"
categories: []
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/ea258c621dc1484fb6d9fdae2bb7d41d.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Git Checkout Using Partial Branch Name Matching

<p>How about this? zsh bash</p>
<p></p>
<pre>CO() {<br />  if [ ! "$1" ] ; then<br />    echo 'usage: CO branch-name'<br />    git branch<br />    return<br />  fi<br />  branchname=$(git branch --format="%(refname:short)" | grep $1)<br />  if [ ! "$branchname" ]; then<br />    echo "branch name not found. $1"<br />    echo "branch names:"<br />    git brahcn<br />    return<br />  fi<br />  git checkout $branchname<br />}</pre>
