How to fetch all Git branches

后端 未结 30 1466
情书的邮戳
情书的邮戳 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:01

    Have tried many ways, only this one is simple and works for me.

    for branch in $(git ls-remote -h git@.git | awk '{print $2}' | sed 's:refs/heads/::')
    do
      git checkout "$branch"
      git pull
    done
    

提交回复
热议问题