How to fetch all Git branches

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

    Looping didn't seem to work for me and I wanted to ignore origin/master. Here's what worked for me.

    git branch -r | grep -v HEAD | awk -F'/' '{print $2 " " $1"/"$2}' | xargs -L 1 git branch -f --track
    

    After that:

    git fetch --all
    git pull --all
    

提交回复
热议问题