Use the git branch-a command to view all local and remote branches (git branch-r can view only remote branches)
Found that many of the branches that have been deleted in the remote repository are still visible locally.
$ git branch-a
movtop
task_develop
* Weibo
remotes/origin/head-Origin/task_develop
Remotes/origin/develop
remotes/origin/fix_composer_repositories_type
remotes/origin/join_weixin_module
remotes/origin/master
remotes/origin/mining-backup
remotes/origin/movtop
remotes/origin/ Right
remotes/origin/schedule_dev
remotes/origin/stuff_web_fix
remotes/origin/task_develop
Remotes/origin/task_idea
remotes/origin/task_temp
remotes/origin/task_yqj
remotes/origin/ Weibo
Remotes/origin/weixin_temp
Using the command git remote show origin, you can see the remote address, the remoting branch, and the corresponding relationship between the local branch and other information.
$ git Remote Show origin * Remote Origin Fetch url:https://xxx@gitlab.com/xxx/xxx.git Push Url:https://xxx@gitla B.com/xxx/xxx.git HEAD branch:task_develop Remote branches:master TR acked Mining-backup tracked Refs/remotes/origin/develop Stale (use ' git remote prune ' to remove) refs/remotes/origin/fix_composer_repositories_type stale (use ' Git remote p Rune ' to remove] refs/remotes/origin/join_weixin_module stale (use ' git remote prune ' to remove) refs/ Remotes/origin/movtop stale (use ' git remote prune ' to remove) refs/remotes/origin/right Stale (use ' git remote prune ' to remove) Refs/remotes/origin/schedule_dev stale (use ' Git remote prune ' to remove) refs/remotes/origin/stuff_web_fix stale (use ' git remote prune ' to Remove) Refs/remoteS/origin/task_temp stale (use ' git remote prune ' to remove) Refs/remotes/origin/weibo
Stale (use ' git remote prune ' to remove) Task_develop tracked
Task_idea tracked Task_yqj tracked Weixin_temp tracked Local branches configured for ' git pull ': movtop Merges with remote Movtop task_develop merges with remote Task_develop Weibo merges with remote Weibo L Ocal ref configured for ' git push ': Task_develop pushes to task_develop (up to date)
At this point we can see those branches that the remote repository does not already exist, and, as prompted, use the Git Remote Prune origin command:
$ git remote prune origin
pruning Origin
url:https://xxx@gitlab.com/xxx/xxx.git
* [pruned] Origin/develop
* [pruned] origin/fix_composer_repositories_type
* [pruned] origin/join_weixin_module
* [pruned] Origin /movtop
* [pruned] origin/right
* [pruned] origin/schedule_dev
* [pruned] origin/stuff_web_fix
* [ Pruned] origin/task_temp
* [pruned] Origin/weibo
This removes the branches that do not exist in the remote repository.