git clone specific list of branches

后端 未结 1 1851
旧巷少年郎
旧巷少年郎 2020-12-22 02:35

I want to clone a list of branches from remote repo. What is the best way to do that without fetching everything? I saw solutions for cloning one specific branch but I need

相关标签:
1条回答
  • 2020-12-22 03:18

    You start with one branch:

    git clone --branch first URL localrepo
    

    and then fetch all the rest:

    cd localrepo
    for branch in second third etc; do
        git fetch origin $branch:$branch
    done
    

    Or without loop

    git fetch origin second:second third:third
    
    0 讨论(0)
提交回复
热议问题