# git-switch-tree script

1 messages from 2005-05-23 to 2005-05-23. Participants: Jeff Garzik.
Thread: https://gitlist.dev/t/700

## Jeff Garzik, 2005-05-23 07:24

Subject: git-switch-tree script
Message-ID: <42918526.1060406@pobox.com>
URL: https://gitlist.dev/e/42918526.1060406%40pobox.com

```
This is what I use to switch between branches, in my kernel trees.

	Jeff




#!/bin/sh

if [ "x$1" != "x" ]
then
	if [ "$1" == "master" ]
	then
		( cd .git && rm -f HEAD && ln -s refs/heads/master HEAD )
	else
		if [ ! -f .git/refs/heads/$1 ]
		then
			echo Branch $1 not found.
			exit 1
		fi

		( cd .git && rm -f HEAD && ln -s refs/heads/$1 HEAD )
	fi
fi

git-read-tree -m HEAD && git-checkout-cache -q -f -u -a


```
