How to fetch all Git branches

后端 未结 30 995
情书的邮戳
情书的邮戳 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 09:54

    We can put all branch or tag names in a temporary file, then do git pull for each name/tag:

    git branch -r | grep origin | grep -v HEAD| awk -F/ '{print $NF}' > /tmp/all.txt
    git tag -l >> /tmp/all.txt
    for tag_or_branch in `cat /tmp/all.txt`; do git checkout $tag_or_branch; git pull origin $tag_or_branch; done
    

提交回复
热议问题