How to Checkout Remote Git Branch

undefined

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

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

Your email address will not be published. Required fields are marked *