Last Updated: February 25, 2016
· jan0sch

Remove multiple remote branches with git

If you want to delete a remote git branch then you can do so using the following command.

% git push origin :BRANCH-NAME

However if you cleanup a repository and have multiple remote branches you want to remove then you could do something like this:

% git branch -r | awk -F/ '/\/SOME-PREFIX/{print $2}' | xargs -I {} git push origin :{}

This will delete all remote branches starting with SOME-PREFIX.

Say Thanks
Filed Under

Awesome Job

20838750 ca12 11e7 8395 3d07316c018d
Overijssel,Amsterdam, Arnhem
Overijssel, Amsterdam, Arnhem
Full Time