1.删除远程分支

在远程下面,选择需要删除的分支,右击,选择删除

2.  删除不存在远程对应分支的本地分支

在远程上建立了一个分支feature,后来leader觉得不合理,就把远程feature分支删除,并又建立了一个feature分支,这导致我在sourceTree上无法pull到最新的版本。

也假设出现这样的情况:

  1. 我创建了本地分支b1并pull到远程分支 origin/b1
  2. 其他人在本地使用fetch或pull创建了本地的b1分支;
  3. 我删除了 origin/b1 远程分支;
  4. 其他人再次执行fetch或者pull并不会删除这个他们本地的 b1 分支,运行 git branch -a 也不能看出这个branch被删除了,如何处理?

[root@test01 H2]# git remote show origin
* remote origin
  Fetch URL: git@hdt.gitlab.com:engine/H2.git
  Push  URL: git@hdt.gitlab.com:engine/H2.git
  HEAD branch: master
  Remote branches:
    H2-Doc                              tracked
    develop                             tracked
    feature/test                        new (next fetch will store in remotes/origin)
    feature/testpush                    new (next fetch will store in remotes/origin)
    feature_ai                          tracked
    feature_lyp                         tracked
    master                              tracked
    refs/remotes/origin/13123123        stale (use 'git remote prune' to remove)
    refs/remotes/origin/LogModModify    stale (use 'git remote prune' to remove)
    refs/remotes/origin/RequestModVideo stale (use 'git remote prune' to remove)
    refs/remotes/origin/feature         stale (use 'git remote prune' to remove)
    refs/remotes/origin/test-1111       stale (use 'git remote prune' to remove)
    refs/remotes/origin/test/test       stale (use 'git remote prune' to remove)
    video                               tracked
  Local branches configured for 'git pull':
    develop merges with remote develop
    master  merges with remote master
  Local refs configured for 'git push':
    develop pushes to develop (local out of date)
    master  pushes to master  (up to date)

这时候能够看到feature是stale的,使用 git remote prune origin 可以将其从本地版本库中去除。

[root@test01 H2]# git remote prune origin
Pruning origin
URL: git@hdt.gitlab.com:engine/H2.git
 * [pruned] origin/13123123
 * [pruned] origin/LogModModify
 * [pruned] origin/RequestModVideo
 * [pruned] origin/feature
 * [pruned] origin/test-1111
 * [pruned] origin/test/test

更简单的方法是使用这个命令,它在fetch之后删除掉没有与远程分支对应的本地分支:

git fetch -p

查看全部分支

[root@test01 H2]# git branch -a
* develop
  master
  remotes/origin/H2-Doc
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/feature_ai
  remotes/origin/feature_lyp
  remotes/origin/master
  remotes/origin/video

可以看到feature分支已经被删除掉了

参考链接   http://blog.csdn.net/ai2000ai/article/details/45021977

代码管理(五)git 删除分支的更多相关文章

  1. 通过代码管理工具 git 完成一次完整的代码管理过程

    1.从公共远程fork一份自己的本地远程之后,从本地远程 clone 到本地 2.将本地代码跟公共远程代码做关联配置 git remote add upstream https://github.co ...

  2. java接口自动化(五) - 企业级代码管理工具Git的配置

    1.简介 上一篇讲解完如何安装Git后,今天宏哥趁热打铁讲解一下Git的使用,要想使用Git,我们还需要做一些准备工作,首先你的拥有一个Git账号,所以如果你没有的话,就快速注册一个吧. 2.Git注 ...

  3. 代码管理工具Git的安装及使用

    一:Git是什么? Git是目前世界上最先进的分布式版本控制系统. 二:SVN与Git的最主要的区别? SVN是集中式版本控制系统,版本库是集中放在中央服务器的,而干活的时候,用的都是自己的电脑,所以 ...

  4. 代码管理工具 Git

    之前一直使用微软的代码管理工具TFS(Team Foundation Server)..NET CORE 2.0的发布后,考虑到.NET CORE项目可以跨平台,准备把项目迁移到.NET CORE 环 ...

  5. SourceTree代码管理学习git命令操作

    Git管理工具SourceTree提交代码时报文件名过长,用命令解决这个错误: 使用git status查看状态信息 git status 使用git add将修改后的文件(.代表全部文件)添加到暂存 ...

  6. 使用代码管理工具(git)管理代码的常用指令合集

    create a new repository on the command line echo "# test" >> README.md git init git ...

  7. 代码管理工具 --- git的学习笔记二《git的工作原理》

    通过几个问题来学习代码管理工具之git 一.git是什么?为什么要用它?使用它的好处?它与svn的区别,在Mac上,比较好用的git图形界面客户端有 git 是分布式的代码管理工具,使用它是因为,它便 ...

  8. 代码管理 ,git 命令整理

    //先要理解这四个概念,这是一个提交代码的流动轨迹:1.工作区(编辑器)-经过add到2- 2.暂存区 (缓存)- 经过commit3-3.本地仓库 (本地项目)-经过 push4-4.远程仓库 (线 ...

  9. Git删除分支/恢复分支

     • 删除一个已被终止的分支 如果需要删除的分支不是当前正在打开的分支,使用branch -d直接删除 git branch -d <branch_name> • 删除一个正打开的分支 如 ...

  10. 代码管理工具-Git基础介绍及常用技巧

    目录 Git起源 基本概念 Branch.HEAD和Commit tree Git分支 git merge 和 git rebase 的区别和抉择 与远程仓库的交互 关于一些实际开发场景的问题和解决方 ...

随机推荐

  1. centos6默认python2.6升级2.7 卸载python2.6升级2.7

    转自:http://blog.csdn.net/u010098331/article/details/52190354 本文介绍CentOS 6.3从自带的Pyhon版本是2.6升级到2.7.6的方法 ...

  2. (算法)Travel Information Center

    题目: Aps Island has many cities. In the summer, many travellers will come to the island and attend fe ...

  3. Python MySQLdb模块连接操作mysql数据库实例_python

    mysql是一个优秀的开源数据库,它现在的应用非常的广泛,因此很有必要简单的介绍一下用python操作mysql数据库的方法.python操作数据库需要安装一个第三方的模块,在http://mysql ...

  4. Serializable 介绍

    今天咱们简单介绍一些serializable. 1.序列化是干什么的? 简单说就是为了保存在内存中的各种对象的状态(也就是实例变量,不是方法),并且可以把保存的对象状态再读出来.虽然你可以用你自己的各 ...

  5. Aerospike系列:4:简单的增删改查aql

    [root@localhost bin]# aql --help Usage: aql OPTIONS OPTIONS -h <host> The hostname to the serv ...

  6. 《Unix&Linux大学教程》学习笔记二:指令常识

    1:指令的本质——调用可执行程序 在Shell输入命令时,其实就是根据名称运行相应的程序. 2:在系统中查找程序 which 指令名 type 指令名 3:时间与日历 date [-选项] 参数 ca ...

  7. cocos2d-js 粒子系统使用自定义图片,还原原来的图片宽高

    粒子系统使用自定义图片很简单只需要在plist最后一行设置png的名称即可.但是,在实际使用中,发现自定义图片无法使用原来的形状,例如设置了一长条的图片,结果出来确实一个个圆球. 翻了plist和cc ...

  8. Oracle Data Integrator 12c----包(Package)

    1 创建"包" Designer->项目->ODI_Exercise ->第一个文件夹->包,右键"新建程序包": "定义&q ...

  9. org.apache.commons.lang.exception包的ExceptionUtils工具类获取getFullStackTrace

    /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreem ...

  10. DDIA

    https://vonng.gitbooks.io/ddia-cn/content/ch7.html