How to fetch all Git branches

后端 未结 30 1425
情书的邮戳
情书的邮戳 2020-11-22 09:38

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
         


        
30条回答
  •  温柔的废话
    2020-11-22 10:09

    The Bash for loop wasn't working for me, but this did exactly what I wanted. All the branches from my origin mirrored as the same name locally.

    git checkout --detach
    git fetch origin '+refs/heads/*:refs/heads/*'
    

    See Mike DuPont's comment below. I think I was trying to do this on a Jenkins Server which leaves it in detached head mode.

提交回复
热议问题