DEV Community

Git: Delete merged branches

miku86 on January 10, 2020

Problem I build an app and use git branches. Branches sum up, I don't know which branches are already merged into master and I lose ove...
Collapse
 
marounmaroun profile image
Maroun Maroun

Add it as an alias in your ~/.gitconfig:

[alias]
    delete-merged = git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
Collapse
 
miku86 profile image
miku86

Great idea!

Collapse
 
thinkdigitalsoftware profile image
ThinkDigitalSoftware

Hey, is this a post with a solution? Do you have a complete script?

Collapse
 
miku86 profile image
miku86

Hey,

there is the Solution (Linux)-section with the two-step solution.
For Windows, there is a link in the Further Reading-section