Web Development
26-02-2025

Remove multiple branches in GIt

Dmytro Tus
Full Stack Web developer

To find the branch which matches some pattern you can execute

git branch | grep 'feature/'

To remove multiple branches in Git that match a pattern like feature/*, you can use the following command:

git branch | grep 'feature/' | xargs git branch -d // safer option ( skip deleting when the branch is not fully merged )

git branch | grep 'feature/' | xargs git branch -D force delete ( delete branches even it is not fully merged )

 

We can also check whether branch is fully merged

git branch --merged

Tags:

Another posts