The voted answer does have the potential to delete master. Consdier the below practical example.
I had two feature branches hemen_README and hemen_BASEBOX which were merged into develop, and then develop was merged into master. The feature branches hemen_README and hemen_BASEBOX were deleted remotely but were still showing up locally. Also i am not on master locally, but on develop.
In that case
hemen@hemen-MXC061:~/data/projects/vagrant-webdev$ git branch -v -a
* develop 671ad6c Merged in hemen_README (pull request #1)
hemen_BASEBOX a535c0f added global exec paths to puppet manifest
hemen_README ba87489 Updated Readme with considerable details
master 8980894 [behind 7] Initial Vagrantfile, works for vagrant up. Also initial .gitignore
remotes/origin/develop 671ad6c Merged in hemen_README (pull request #1)
remotes/origin/hemen_BASEBOX a535c0f added global exec paths to puppet manifest
remotes/origin/hemen_README ba87489 Updated Readme with considerable details
remotes/origin/master 2f093ce Merged in develop (pull request #3)
So if i run the above partial command
hemen@hemen-MXC061:~/data/projects/vagrant-webdev$ git branch --merged | grep -v "\*"
hemen_BASEBOX
hemen_README
master
Notice that it shows master too, which will eventually be deleted.
In any case I was able to do it. I am sharing my session log with you on how I achieved that.
hemen@hemen-MXC061:~/data/projects/vagrant-webdev$ git remote prune origin --dry-run
Pruning origin
URL: git@bitbucket.org:hemenkapadiapublic/vagrant-webdev.git
* [would prune] origin/hemen_BASEBOX
* [would prune] origin/hemen_README
hemen@hemen-MXC061:~/data/projects/vagrant-webdev$ git remote prune origin
Pruning origin
URL: git@bitbucket.org:hemenkapadiapublic/vagrant-webdev.git
* [pruned] origin/hemen_BASEBOX
* [pruned] origin/hemen_README
I just checked whay will be pruned and then pruned it. looking at branch command below we have taken care of remotes
hemen@hemen-MXC061:~/data/projects/vagrant-webdev$ git branch -v -a
* develop 671ad6c Merged in hemen_README (pull request #1)
hemen_BASEBOX a535c0f added global exec paths to puppet manifest
hemen_README ba87489 Updated Readme with considerable details
master 8980894 [behind 7] Initial Vagrantfile, works for vagrant up. Also initial .gitignore
remotes/origin/develop 671ad6c Merged in hemen_README (pull request #1)
remotes/origin/master 2f093ce Merged in develop (pull request #3)
Now go ahead and delete local branches
hemen@hemen-MXC061:~/data/projects/vagrant-webdev$ git branch -d hemen_BASEBOX
Deleted branch hemen_BASEBOX (was a535c0f).
hemen@hemen-MXC061:~/data/projects/vagrant-webdev$ git branch -d hemen_README
Deleted branch hemen_README (was ba87489).
Good now the branches are as desired.
hemen@hemen-MXC061:~/data/projects/vagrant-webdev$ git branch -v -a
* develop 671ad6c Merged in hemen_README (pull request #1)
master 8980894 [behind 7] Initial Vagrantfile, works for vagrant up. Also initial .gitignore
remotes/origin/develop 671ad6c Merged in hemen_README (pull request #1)
remotes/origin/master 2f093ce Merged in develop (pull request #3)