I cloned a Git repository containing many branches. However, git branch only shows one:
$ git branch
* master
How would I pull all the branches locally so when I do git branch, it shows the following?
$ git branch
* master
* staging
* etc...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
TL;DR answer
(It seems that pull fetches all branches from all remotes, but I always fetch first just to be sure.)
Run the first command only if there are remote branches on the server that aren’t tracked by your local branches.
Complete answer
You can fetch all branches from all remotes like this:
It’s basically a power move.
fetchupdates local copies of remote branches so this is always safe for your local branches BUT:fetchwill not update local branches (which track remote branches); if you want to update your local branches you still need to pull every branch.fetchwill not create local branches (which track remote branches), you have to do this manually. If you want to list all remote branches:git branch -aTo update local branches which track remote branches:
However, this can be still insufficient. It will work only for your local branches which track remote branches. To track all remote branches execute this oneliner BEFORE
git pull --all:P.S. AFAIK
git fetch --allandgit remote updateare equivalent.Kamil Szot’s comment, which folks have found useful.