The OP did not ask for cleanup for all remotes, rather for all branches of default remote.
So git fetch --prune
is what should be used.
Setting git config remote.origin.prune true
makes --prune
automatic. In that case just git fetch
will also prune stale remote branches from the local copy. See also Automatic prune with Git fetch or pull.
Note that this does not clean local branches that are no longer tracking a remote branch. See How to prune local tracking branches that do not exist on remote anymore for that.