How to fetch all Git branches

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

    To avoid the error message 'fatal: A branch named 'origin/master' already exists.', you may try my solution:

    git branch -r | grep -v '\->'  | grep -v `git branch | awk '/\*/ { print $2; }'`| while read remote; do git branch --track "${remote#origin/}" "$remote"; done
    

提交回复
热议问题