Home  >  Article  >  Development Tools  >  How to batch delete branches in git

How to batch delete branches in git

WBOY
WBOYOriginal
2022-01-04 16:35:0612428browse

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.

How to batch delete branches in git

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 :{}

Recommended study: "Git Tutorial"

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What exactly does svn do?Next article:What exactly does svn do?