0 votes
1 view
in Devops and Agile by (20k points)

I have many Git branches. How do I delete branches which have already been merged? Is there an easy way to delete them all instead of deleting them one by one?

1 Answer

0 votes
by (28.4k points)

In order to delete all branches on remote that are already merged:

git branch -r --merged | grep -v master | sed 's/origin\//:/' | xargs -n 1 git push origin

In more recent versions of Git, this command can also be used:

git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...