Delete local branches that have been deleted on the remote

suggest change

To drop remote-tracking branches whose upstream branch was deleted:

git fetch -p

You can then use

git branch -vv

to see which branches are no longer being tracked.

Branches that are no longer being tracked will be in the form below, containing ‘gone’

branch               12345e6 [origin/branch: gone] Fixed bug

You can then use a combination of the above commands, looking for where ‘git branch -vv’ returns ‘gone’ then using ‘-d’ to delete the branches

git fetch -p && git branch -vv | awk '/: gone]/{sub(/^\*/, ""); print $1}' | xargs git branch -d

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents