#!/bin/bash if [ ! -d .git ]; then echo Does not appear to be a git tree exit 1 fi if [ "$1"x == x ]; then echo Need remote branch exit 1 fi SRC=$1 if [ ! -f .git/refs/remotes/origin/$SRC ]; then echo Remote branch $SRC does not exist exit 2 fi if [ "$2"x != x ]; then DST=$2 else DST=$SRC fi cp .git/refs/remotes/origin/$SRC .git/refs/heads/$DST