使用命令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. ORM简单增删改查

    namespace ORM { class Program { static void Main(string[] args) { //AddPetStore();//添加 UpdatePetStor ...

  2. Delphi 媒体播放器控件

    樊伟胜

  3. 1.Bacula各组件说明

    1.  Bacula各组件说明 Baula有三个服务,分别是bacula-sd用于管理storage.bacula-fd为bacula客户端.bacula-dir为bacula的核心组件机direct ...

  4. WiFi 6是否适合个人用户

    5G已经被热炒得家喻户晓,但与其对标的WiFi新技术标准——Wi-Fi 6却可能有着更好的经济和技术前景,WiFi 6也称为802.11ax,比过去的Wi-Fi技术更好,速度更快能跟5G对标,连接性更 ...

  5. 1.RPC原理学习

    1.什么是RPC:远程过程调用协议 RPC(Remote Procedure Call Protocol)— 远程过程调用协议,是一种通过网络从远程计算机程序上请求服务,而不需要 了解底层网络技术的协 ...

  6. 基于Hexo的个人博客搭建(上)

    没有废话,直接开始. 1. 环境配置 —1.1 node.js安装 https://nodejs.org/en/download/ 下载最新版本即可,然后无脑安装(除了选安装目录的时候),为了保证安装 ...

  7. 计算机基础之BIOS

    BIOS BIOS是英文"Basic Input Output System"的缩略词,直译过来后中文名称就是"基本输入输出系统".在IBM PC兼容系统上,是 ...

  8. css实现单行、多行文本超出显示省略号

    前言:项目中我们经常遇到这种需求,需要对单行.多行文本超出显示为省略号.这篇文章主要总结了小编解决此问题的方法,有不足之处欢迎大家指正. 单行文本省略 .ellipsis-line { border: ...

  9. SSH框架整合报错org.springframework.web.context.ContextLoaderListener

    是因为在导入的jar包中缺少了一个 org.springframework.web_3.1.4.release.jar 在网上下载即可 下载地址: http://www.java2s.com/Code ...

  10. python在window下环境搭建

    1.Python安装包下载 地址:https://www.python.org/downloads/windows/ 然后找到对应系统版本的安装包 下载完成后,直接运行exe安装.在安装的时候开业勾选 ...