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

后端 未结 14 2436
广开言路
广开言路 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条回答
  •  -上瘾入骨i
    2020-12-12 13:34

    To remove all merged branches(except current -v ‘*’):

    git branch --merged | grep -v '*' | xargs git branch -D
    

    also I made such command for repo complete clean up:

    alias git-clean="git branch  | grep -v '*' | grep -v 'master' | xargs git branch -D  && git reset --hard && git clean -d -x -f"
    

    taken from here.

提交回复
热议问题