Git Hub Clone All Branches At Once

后端 未结 7 1091
时光取名叫无心
时光取名叫无心 2020-12-07 12:19

I\'m trying to clone an entire repository onto my machine using linux. I used

git clone    

I then went into the folder where i

7条回答
  •  天涯浪人
    2020-12-07 12:41

    (1) Inside git local repostitory, create a new sh file

    touch getAllBranches.sh
    vi getAllBranches.sh
    

    (2) Insert the below content to getAllBranches.sh file:

    for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
       git branch --track ${branch#remotes/origin/} $branch
    done
    

    (3) Get all branches:

    chmod +x getAllBranches.sh    
    sh getAllBranches.sh
    

    (4) Check result at local repository:

    git branch
    

    For example, I use repository: https://github.com/donhuvy/spring-boot

    As you can see, I have fetched all branches to local machine:

提交回复
热议问题