git删除远程分支

2018-03-05  本文已影响13人  朽木自雕也

最近公司项目不忙在网上买了一本《git学习指南》,系统的学习一遍git操作,这本书写得不怎么地,实话,很多方面第一没有讲到,遇到问题都是去网上观摩大神写的文章,不逼逼,说一个今天的问题删除远程分支
命令整合一下
列出本地分支:
git branch
列出远程分支
git branch -r
删除本地分支:
git branch -D branchName
其中-D也可以是--delete,如:
git branch --delete branchName
删除远程git服务器上的分支:
git push origin -d branchName

先创建一个分支并推送到远程版本库
chenxuemingdeMacBook-Air:GitTest chenxueming$ git branch test
chenxuemingdeMacBook-Air:GitTest chenxueming$ git push origin test:test
Total 0 (delta 0), reused 0 (delta 0)
To https://gitee.com/chenXueMing/GitTest.git

3月-05-2018 11-28-16.gif

在来本地查看一下远程分支
chenxuemingdeMacBook-Air:GitTest chenxueming$ git branch -r
origin/HEAD -> origin/master
origin/develop
origin/master
问题出现了,远程git库origin/develop分支已经删除掉了,但是本地查看远程库还存在尝试使用 git fetch 命令也没用
chenxuemingdeMacBook-Air:GitTest chenxueming$ git fetch
chenxuemingdeMacBook-Air:GitTest chenxueming$ git branch -r
origin/HEAD -> origin/master
origin/develop
origin/master
然后git help fetch,看到这样一个东西
-p, --prune
Before fetching, remove any remote-tracking references that no
longer exist on the remote. Tags are not subject to pruning if they
are fetched only because of the default tag auto-following or due
to a --tags option. However, if tags are fetched due to an explicit
refspec (either on the command line or in the remote configuration,
for example if the remote was cloned with the --mirror option),
then they are also subject to pruning.
我英文不好,大概就是,删除不需要的远程跟踪。
试了一下这个命令 git fetch -p ,挺管用的
chenxuemingdeMacBook-Air:GitTest chenxueming$ git help fetch
chenxuemingdeMacBook-Air:GitTest chenxueming$ git fetch -p
From https://gitee.com/chenXueMing/GitTest

上一篇下一篇

猜你喜欢

热点阅读