• 0

Get a remote branch into your freshly cloned local repository

If you have just cloned a repository, by default git places you on the master branch. Even if you do a ‘git branch’ it just shows you the master branch because that is all you have locally. However, if you want to work on another remote branch instead of the master, you will first need to do a checkout that remote branch. You heard that right, you gotta checkout a branch that is not even listed on your local repository.

To know what branch you need to checkout from your remote, run the command

git branch -a

Lets say your origin had a branch called bug-01. Then, to checkout that branch, run

git branch --track bug-01 origin/bug-01

Of course, you can also specify a completely different branch name during checkout. e.g.

git branch --track bug-01-is-a-feature origin/bug-01