使用命令git branch -a可以查看所有本地分支和远程分支(git branch -r 可以只查看远程分支) 
如果发现很多在远程仓库已经删除的分支在本地依然可以看到到底该怎么办呢?(反正强迫症受不了一定要把本地的也同步删除了)

$ 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

使用命令 git remote show origin可以查看remote地址,远程分支,还有本地分支与之相对应关系等信息。

$ git remote show origin  

* remote origin
Fetch URL: https://xxx@gitlab.com/xxx/xxx.git
Push URL: https://xxx@gitlab.com/xxx/xxx.git
HEAD branch: task_develop
Remote branches:
master tracked
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 prune' 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
Local ref configured for 'git push':
task_develop pushes to task_develop (up to date)

此时我们可以看到那些远程仓库已经不存在的分支,根据提示,使用 git remote prune origin 命令:

$ 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

这样就删除了那些远程仓库不存在的分支。

git远程删除分支后,本地执行git branch -a依然能看到删除分支到底该咋整?的更多相关文章

  1. windows 切换git远程仓库地址后 git push 提示Authentication failed

    git切换远程分支: 方法一: git remote set-url origin 你新的远程仓库地址 方法二: git remote rm origin git remote add origin ...

  2. Git远程仓库地址变更本地如何修改

    以项目test为例: 老地址:http://192.168.1.1:9797/john/test.git 新地址:http://git.xxx.xxx/john/test.git 远程仓库名称: or ...

  3. git 远程仓库版本的回退以及git reset 几种常用方式记录

    由于 github push 了两个比较潦草的commit, 自己很不满意,又不想重新开vpn进行上传,所以找了一下相关的教程. 最后研究了一下,原理为先在本地还原到你想要的commit,然后强制pu ...

  4. git远程建立仓库后,将本地项目推到远程报错 fatal: refusing to merge unrelated histories

    出现这个问题的最主要原因还是在于本地仓库和远程仓库实际上是独立的两个仓库,假如之前是直接clone的方式在本地仓库就不会有这个问题了. 解决方式是在命令后紧跟 --allow-unrelated-hi ...

  5. git项目远程地址修改后本地如何处理

    今天运维人员为了方便管理,将远程的项目地址给迁移了, 原来是 git@git.lalala.com:yuanlaide/happy.git 变成了 git@git.lalala.com:houlaid ...

  6. Mac 升级后idea执行git命令报错xcrun: error: invalid active developer path的解决办法

    报错 xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun ...

  7. 创建局域网内远程git仓库,并将本地仓库push推到远程仓库中

    转载请注明出处 http://www.goteny.com/articles/2014/06/136.html http://www.cnblogs.com/zjjne/p/3778640.html ...

  8. git远程分支不显示问题解决

    因为项目太大,然后直接git clone拉不下来代码 会报error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 5 ...

  9. git 代码上传至远程仓库&从远程库克隆到本地

    1.下载安装Git.下载:https://git-scm.com/downloads  安装:可参考文章http://blog.csdn.net/zzfenglin/article/details/5 ...

随机推荐

  1. 日常开发用Windows 好还是 Ubuntu好?

    最近打算给电脑重新装系统,纠结了很久,不知道应该是换Windows还是Ubuntu,今天通过我自身的体验,来为大家分析一下,日常开发环境到底是用Windows和Ubuntu. [系统介绍] Windo ...

  2. sql 存储过程笔记2

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sys_Page_v2]') and OBJECTPROPE ...

  3. 如何使用ssh工具便于远程管理

    前几天亲眼经历了Linux服务器运维过程,眼看着别人熟练运用Linux管理工具,自个心里不是滋味,所以自己特意整理了一篇“专题”:使用ssh服务远程管理主机. 首先在使用ssh服务工具之前,先熟悉下L ...

  4. Redis05——Redis高级运用(管道连接,发布订阅,布隆过滤器)

    Redis高级运用 一.管道连接redis(一次发送多个命令,节省往返时间) 1.安装nc yum install nc -y 2.通过nc连接redis nc localhost 6379 3.通过 ...

  5. golang-vue实现微信小程序分享到朋友圈

    最近涉及到微信小程序分享到朋友圈,不知道微信为什么不直接接口分享,咱也不敢佛,咱也不敢问,只能百度问度娘,看官方文档,网上的一些分享五花八门,每一个重点的,所以整理了一下到底怎样生成二维码分享图片才是 ...

  6. (七)zabbix监控nginx

    1.agent端配置 1)nginx编译安装需要加上该选项--with-http_stub_status_module 2)修改nginx配置文件 #vim /usr/local/nginx/conf ...

  7. Linux Bonding

    https://www.cnblogs.com/huangweimin/articles/6527058.html 管理   linux下网卡bonding配置   章节 bonding技术 cent ...

  8. 深入理解JavaScript执行上下文、函数堆栈、提升的概念

    本文内容主要转载自以下两位作者的文章,如有侵权请联系我删除: https://feclub.cn/post/content/ec_ecs_hosting http://blog.csdn.net/hi ...

  9. BZOJ 2219 数论之神 (CRT推论+BSGS+原根指标)

    看了Po神的题解一下子就懂了A了! 不过Po神的代码出锅了-solve中"d-temp"并没有什么用QwQQwQQwQ-应该把模数除以p^temp次方才行. 来自BZOJ讨论板的h ...

  10. MyBatis注解开发-@Insert和@InsertProvider

    @Insert和@InsertProvider都是用来在实体类的Mapper类里注解保存方法的SQL语句.不同的是,@Insert是直接配置SQL语句,而@InsertProvider则是通过SQL工 ...