Delete multiple remote branches in git

前端 未结 18 2470
轮回少年
轮回少年 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

    I was not able to use awk because we are using a slash structure for our branches' name.

    git branch -r | grep "origin/users/YOURNAME" | sed -r 's/^.{9}//'| xargs -i  sh -c 'git push origin --delete {}'
    

    This get all remote branch, get only the one for a single user, remote the "origin/" string and execute a delete on each of them.

提交回复
热议问题