git

Delete git branch not in remote

goffity

Goffity Corleone

Posted on April 15, 2022

Delete git branch not in remote

I'm not sure where I received the information, but it was most likely from stackoverflow.

git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
Enter fullscreen mode Exit fullscreen mode

Update 2022-08-02

git checkout develop && git branch --merged | grep -v 'main' | grep -v 'develop' >/tmp/merged-branches && vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches
Enter fullscreen mode Exit fullscreen mode

Ref: https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote

💖 💪 🙅 🚩
goffity
Goffity Corleone

Posted on April 15, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related