Delete local branches that have been deleted on the remote
suggest changeTo 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents