How to Checkout Remote Git Branch

Channel: Linux
Abstract: git checkout -b staging origin/stagingThis tutorial will help you to check out a remote git branch that is not available on the local git repository.

This tutorial will help you to check out a remote git branch that is not available on the local git repository. Use command git branch to list local branches available.

Git Checkout Remote 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 the above commands again run ‘git branch’ command to view local branches and current active branch.

git branch

  master
* staging

Ref From: tecadmin

Related articles