DEV Community

Goffity Corleone
Goffity Corleone

Posted on • Edited on

3 3

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

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay