How to fetch all Git branches

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

    If you are here seeking a solution to get all branches and then migrate everything to another Git server, I put together the below process. If you just want to get all the branches updated locally, stop at the first empty line.

    git clone 
    git branch -r | awk -F'origin/' '!/HEAD|master/{print $2 " " $1"origin/"$2}' | xargs -L 1 git branch -f --track 
    git fetch --all --prune --tags
    git pull --all
    
    git remote set-url origin 
    git pull
    
    git push --all
    git push --tags
    
    

提交回复
热议问题