Home >Development Tools >git >How to batch delete branches in git
Method: 1. Use the "git branch|grep "option"|xargs git branch-d" command to delete the local branch; 2. Use the "git branch|grep "option"|xargs git push origin--delete ” command deletes the remote branch.
The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.
How does git delete branches in batches
git batch deletes local branches
Enter the project, for example, if you want to delete all local features Branch, just execute the following command:
git branch -a | grep "^ feature*" | xargs git branch -D
git batch delete remote branches
Enter the project, for example, if you want to delete the release branch starting with 201803, just execute the following command:
git branch -a | grep -o "release/201803.*" | xargs -I {} git push origin :{}
The above is the detailed content of How to batch delete branches in git. For more information, please follow other related articles on the PHP Chinese website!