Delete multiple remote branches in git

前端 未结 18 2494
轮回少年
轮回少年 2020-12-07 07:11

I have a team member who inadvertently pushed over 150 of his local branches to our central repo. Thankfully, they all have the same prefix. Using that prefix, is there a gi

18条回答
  •  清歌不尽
    2020-12-07 07:53

    Thanks to Neevek. This worked well after reconfiguring it for my purpose:

    git branch -r | awk -Forigin/ '/\/PATTERN/ {print $2 "/" $3}' | xargs -I {} git push origin :{}
    

    I also needed take the folder structure into account. My feature-branches are in a folder structure like origin/feature/PREFIX-FEATURENUMBER. So i had to build up my pattern from $2=folder + $3= branchname.

提交回复
热议问题