How to Track a new remote branch created on GitHub

Published on Author Code Father
git fetch
git branch --track branch-name origin/branch-name

First command makes sure you have remote branch in local repository. Second command creates local branch which tracks remote branch. It assumes that your remote name is originand branch name is branch-name.

--track option is enabled by default for remote branches and you can omit it.

 

—————————- OR ——————————————————–

First of all you have to fetch the remote repository:

git fetch remoteName

Than you can create the new branch and set it up to track the remote branch you want:

git checkout -b newLocalBranch remoteName/remoteBranch

You can also use “git branch –track” instead of “git checkout -b” as max specified.

git branch --track newLocalBranch remoteName/remoteBranch

Comments

comments

Categories Git