syropian
6/17/2013 - 8:58 PM

Add this to your bash profile if you want to easily create a remote branch and then checkout a local branch that tracks it.

Add this to your bash profile if you want to easily create a remote branch and then checkout a local branch that tracks it.

function git-cb() {
  if [ $# -ne 1 ]; then
    echo 1>&2 Usage: git-cb branch_name
  else
    git push origin origin:refs/heads/$1
    git fetch origin
    git checkout --track -b $1 origin/$1
    git pull
  fi
}