使用 git branch -a
命令可以查看所有本地分支和远程分支(git branch -r 可以只查看远程分支)
发现很多在远程仓库已经删除的分支在本地依然可以看到。
$ git branch -r
origin/DEVS-193
origin/DEVS224-216
origin/HEAD -> origin/master
origin/REGS-ECT-V0.0.1-jasonhe
origin/REGS-ECT-V0.0.3-jasonhe
origin/XQ181012153932752566128
origin/XQ181030154088131757713
origin/audit
origin/bug
origin/dev
origin/master
origin/test
使用命令 git remote show origin
,可以查看remote地址,远程分支,还有本地分支与之相对应关系等信息。
$ git remote show origin
* remote origin
Fetch URL: git@git.igfresh.com:regs/sso_seastar.git
Push URL: git@git.igfresh.com:regs/sso_seastar.git
HEAD branch: master
Remote branches:
REGS-ECT-V0.0.1-jasonhe tracked
REGS-ECT-V0.0.3-jasonhe tracked
audit tracked
bug tracked
dev tracked
master tracked
refs/remotes/origin/DEVS-193 stale (use 'git remote prune' to remove)
refs/remotes/origin/DEVS224-216 stale (use 'git remote prune' to remove)
refs/remotes/origin/XQ181012153932752566128 stale (use 'git remote prune' to remove)
refs/remotes/origin/XQ181030154088131757713 stale (use 'git remote prune' to remove)
test tracked
Local branch configured for 'git pull':
dev merges with remote dev
Local ref configured for 'git push':
dev pushes to dev (up to date)
此时我们可以看到那些远程仓库已经不存在的分支,根据提示,使用 git remote prune origin
命令:
$ git remote prune origin
Pruning origin
URL: git@git.igfresh.com:regs/sso_seastar.git
* [pruned] origin/DEVS-193
* [pruned] origin/DEVS224-216
* [pruned] origin/XQ181012153932752566128
* [pruned] origin/XQ181030154088131757713
此时再查看远程分支:
$ git branch -r
origin/HEAD -> origin/master
origin/REGS-ECT-V0.0.1-jasonhe
origin/REGS-ECT-V0.0.3-jasonhe
origin/audit
origin/bug
origin/dev
origin/master
origin/test