litany against fear

coding with spice ¤ by nick quaranto

Checkout tracked remote branch with Git

published 07 Jan 2009

I frequently need to do this when setting up or syncing my various machines, and I seem to forget the command all the time. So let’s say you’ve got more than one branch on your remote, and you want to bring it down into your local repository as well:

Viewing information on the remote should look something like this:

$ git remote show origin
  * remote origin
    URL: *************
    Remote branch merged with 'git pull' 
      while on branch master
        master
      Tracked remote branches
        haml master

Luckily, the command syntax for this is quite simple:

git checkout --track -b <local branch> <remote>/<tracked branch>

So in my case, I used this command:

git checkout --track -b haml origin/haml

You can also use a simpler version:

git checkout -t origin/haml



email twitter github