How to Checkout Remote Git Branch

This tutorial will help you to checkout remote git branch which is not available on local git repository. Use command git branch to list local branches available.

Checkout Remote Git Branch

Now use command git branch -a to list all available branches on local and remote git repository. After that run command git fetch command to update your remote-tracking branches under refs/remotes//. Now checkout new branch to your local system using git checkout branch_name.
$ git fetch $ git checkout staging 

Have Multiple Remotes ?

If you are using multiples remotes, you have to specify remote name with remote branch name like below command Syntax:
$ git checkout -b local_branch_name remote_name/remote_branch_name 
Command:
$ git checkout -b staging origin/staging 
After completing above commands again run ‘git branch’ command to view local branches and current active branch.
$ git branch    master * staging 

Thanks for Visit Here

Comments