DEV Community

Discussion on: Command Line Snippets do you keep handy?

Collapse
 
pavelloz profile image
Paweł Kowalski • Edited
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d

Removes branches that are marked as remote on your machine, but dont exist on origin.

If it complains, replace -d with -D at the end.

Used after git fetch prune.

It keeps branch list tidy and real.

Collapse
 
jrohatiner profile image
Judith

excellent!