Loading...

Git Tutorial

Adding a tracking branch in git

Lets 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.

Step1:Add a local branch tracking the remote branch.

RUN:

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

RESULT:

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

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