git技巧:刪除在本地有但在遠端庫中已經不存在的分支
$ git remote show origin
可以檢視遠端庫的一些資訊,及與本地分支的資訊。有時候可能遇到如下情況
$ git remote show origin
* remote origin
Fetch URL: ... .git
Push URL: ... .git
HEAD branch: master
Remote branches:
dev tracked
jqmobi tracked
master tracked
refs/remotes/origin/3.1 stale (use 'git remote prune' to remove)
refs/remotes/origin/tc stale (use 'git remote prune' to remove)
refs/remotes/origin/xhl stale (use 'git remote prune' to remove)
Local branches configured for 'git pull':
dev merges with remote dev
master merges with remote master
Local refs configured for 'git push':
dev pushes to dev (up to date)
jqmobi pushes to jqmobi (up to date)
master pushes to master (up to date)
其中3.1, tc, xhl三個分支在遠端庫已經不存在了(你之前從遠端庫拉取過,可能之後被其他人刪除了,你用 git branch -a 也是不能看出它們是否已被刪除的),這時候我們可以刪除本地庫中這些相比較遠端庫中已經不存在的分支:
$ git remote prune origin
Password for '...':
Pruning origin
URL: ... .git
* [pruned] origin/3.1
* [pruned] origin/tc
* [pruned] origin/xhl
---------------------
原文:https://blog.csdn.net/xhl_will/article/details/8450193