Delete all local untracked branches from GIT

This is a very handy command for cleaning up all the branches you already merged and closed on origin GIT server. Feel free to use and comment if you have any issues.

git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d

Link of the Gist to share and comment.

Also, some branches are not fully merged and will need to be deleted manually. Then you use:

git branch -D branch_name

Hope that it helps you!

Also published on Medium.

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Esse site utiliza o Akismet para reduzir spam. Aprenda como seus dados de comentários são processados.