Git: Remove tracking branches no longer on remote
Short version: Use this command:
1 | git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done |
Original answer: After the command
1 | git fetch -p |
re 继续>