Track all remote git branches as local branches

前端 未结 15 2297
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 09:01

Tracking a single remote branch as a local branch is straightforward enough.

$ git checkout --track -b ${branch_name} origin/${branch_name}
<
15条回答
  •  余生分开走
    2020-11-22 09:31

    Here is my solution of BASH command referring by @tjmcewan:

    for remote in `git branch -r | grep -v /HEAD `; do git branch --track ${remote/"origin/"/""}; done
    

    My goal is to solve the problem that all the created branches will have "origin/" as the start of the name, because I tested that $remote variables are still include "origin/":

    for remote in `git branch -r | grep -v /HEAD`; do echo $remote ; done
    

提交回复
热议问题