People often use git branch –a to view all branches, including local and remote. But after a long time, you will find that some branches have been deleted long ago in the remote, but you can still see these deleted branches locally. The following describes how to synchronously delete branches that have been deleted remotely but not locally.
1. Use git branch -a to view local branches and all remote branches
In fact, the red part above has been deleted remotely, but the local branch still exists.
2. View local branches and tracking
git remote show origin
It shows that the branch at the red box no longer exists in the remote warehouse [deleted], and it can be used according to the prompt.
git remote prune to delete these branches synchronously.
3. Run the command to delete synchronously
git remote prune origin
You can see that the branch in the red box is deleted, that is, the branch deleted by the remote branch has been deleted synchronously locally.