When you use Git, you often find that you create a large number of branches unconsciously. So, the trouble is coming, so many abandoned branches, what should be done?
You can't always do a git branch-d branchname delete it!
Here's a way to bulk delete a branch:
Git branch |grep ' branchname ' |xargs git branch-d
This is the function of the bulk deletion branch implemented through the shell Pipe command
Git branch output Current branch list
grep matches the output of Git branch, and the matching value is of course branchname
The function of the xargs is to convert the argument list to a small block fragment and pass it to another command
Therefore, this order means:
Matches the branch list to the specified branch, and then one (divided into small chunks) is passed to the command to delete the branch, which is finally deleted.
That's how we want to bulk delete the branch.