Tracking a single remote branch as a local branch is straightforward enough.
$ git checkout --track -b ${branch_name} origin/${branch_name}
<
Using bash:
after git 1.9.1for i in `git branch -a | grep remote | grep -v HEAD | grep -v master`; do git branch --track ${i#remotes/origin/} $i; done
before git 1.9.1credits: Val Blant, elias, and Hugo
Note: the following code if used in later versions of git (>v1.9.1) causes
- (bug) All created branches to track master
- (annoyance) All created local branch names to be prefixed with
origin/
for remote in `git branch -r `; do git branch --track $remote; done
Update the branches, assuming there are no changes on your local tracking branches:
for remote in `git branch -r `; do git checkout $remote ; git pull; done
Ignore the ambiguous refname warnings, git seems to prefer the local branch as it should.