I am adding this answer just to add one point to @bk2204 answer.
If one or more of the branches in the remote is deleted and you don't want to see the remote deleted branches in your local repository then you can use the below git command for only removing the deleted remote branches.
git remote prune
This will only give you the information about the remote branches which is deleted and removes the same branches from the local.
The command git fetch --prune
or git fetch -p
fetches the remote current state first and the deletes the refs to branches in local that doesn' exist in the remote.
I can say that git fetch --prune
is more likely a combination of git fetch
and git remote prune
. Note that git fetches the remote state first before pruning.
Now, you have option choose either of them according to the requirements or demands. ✨