git fetch all branches- How to fetch all Git branches?

DevOps

I cloned a Git repository, which contains about five branches. However, when I do git branch I only see one of them:

$ git branch

* master

I know that I can do git branch -a to see all the branches, but how would I pull all the branches locally so when I do git branch, it shows the following?

$ git branch

* master

* staging

* etc...

2
Answers

Replies

The command to list all the branches is,



git branch -r



If you want to check them as local branches,



git checkout -b LocalName origin/remote-branch-name

 

The git fetch command will be able to fetch all the branches from all remotes.



git fetch --all



This command will not update or create local branches. 



If you want to list all the remote branches, 



git pull --all

 
 

If you want to unleash your potential in this competitive field, please visit the DevOps course page for more information, where you can find the DevOps tutorials and DevOps frequently asked interview questions and answers as well.

 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.