简体   繁体   中英

pull all the git repository branches

How can I pull all the git branch of my repository.

I tried this and this question's few answers, but doesn't seem to do the job for me.

There are three branches, but when I do

git branch

It only shows the master branch.

git branch -a

gives this output

 * master
  origin/HEAD
  origin/development
  origin/feature1
  origin/master
  remotes/origin/HEAD -> origin/master
  remotes/origin/development
  remotes/origin/feature1
  remotes/origin/master

So, I am unable to checkout to feature1 branch and hence cannot check the code residing at the feature1

Please help

When you do git fetch , you actually retrieve all the branches of the remote repository (you can do git fetch --all if you have several remote repositories)

If git branch -a gives you

* master
origin/HEAD
origin/development
origin/feature1
origin/master
remotes/origin/HEAD -> origin/master
remotes/origin/development
remotes/origin/feature1
remotes/origin/master

and you're interested in feature1 , then you just need to do git checkout origin/feature1 . Now you can even do git branch feature1 if you want a local branch.

I have used the git in one of my projects.
Step 1: Do checkout for all the branches as source (ie, at repository level).
Step 2: Next time while pulling the repository to some other site will bring all those branches.

You can switch to any branch by checkout command from the pulled repository.

Hope this would solve your problem. Amol

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM