45. Adding a tracking branch


  • To learn how to add a local branch that tracks a remote branch.

Branches that start with remotes/origin belong to the the original repository. Note that you don’t have a style branch anymore, but it knows that it was in the original repository.

01 Add a local branch tracking the remote branch.


git branch --track style origin/style
git branch -a
git hist --max-count=2


$ git branch --track style origin/style
Branch style set up to track remote branch style from origin.
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
$ git hist --max-count=2
* 2faa4ea 2011-03-09 | Changed README in original repo (HEAD, origin/master, origin/HEAD, master) [Alexander Shvets]
* 6e6c76a 2011-03-09 | Updated index.html (origin/style, style) [Alexander Shvets]

Now we can see the style branch in the branch list and log.