Wednesday, April 29, 2015

Git:Checkout to newly added remote branch

For example, If new branch is added to the repository and now you wanted to setup that in your local system.

$ git fetch

This will look up the origin and update the local repository with the new data.

For example, newly added branch is 'master'. It will show something like this.

$ git branch -r

Above command tell you what are all the remote branches available.

$git checkout -b master origin/master

This will create a new branch 'master' and will have a synch with remote branch /origin/master'

KKOLIPAKA-MBP:$ git fetch
 * [new branch]      master -> origin/master

KKOLIPAKA-MBP:$ git branch -r
  origin/HEAD -> origin/development

KKOLIPAKA-MBP:$ git checkout -b master origin/master
Checking out files: 100% (453/453), done.
Branch master set up to track remote branch master from origin.

Switched to a new branch 'master'

No comments:

Post a Comment