Can I delete all the local branches except the current one?

后端 未结 14 2474
广开言路
广开言路 2020-12-12 13:07

I want to delete all branches that get listed in the output of ...

$ git branch

... but keeping current branch, in one step. Is th

14条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 13:21

    IMHO, the safest way of removing local branches is:

    git branch -av | grep "\[gone\]" | awk '{print $1}' | xargs git branch -d
    

    Also, more info related to this topic you can find Delete all local git branches

提交回复
热议问题