如何仅从本地git删除远程分支? [英] How to remove remote branch only from my local git?

查看:102
本文介绍了如何仅从本地git删除远程分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道命令 git push -d< remote>< branch_name>

我只想从我的本地git env 中删除远程分支.上面的命令也会从我的本地和远程github上删除远程分支.

I want to delete remote branch only from my local git env. The command above removes remote branch from my local and remote github also.

但是,如果我像这样直接在github 中删除了远程分支

However, if I had removed remote branch in github directly like this,

远程中不再有名为 feature/search 的分支,该命令将失败.

there is no branch named feature/search in remote anymore, the command fails.

那么,如何在不与远程github交互的情况下删除本地的远程分支?

So, how can I remove remote branch in my local without interacting remote github?

推荐答案

以前在此处回答..strong>

Previously answered here.

您可以使用 git branch -D git branch -d 在本地删除分支.

You can use git branch -D or git branch -d for deleting a branch locally.

来自官方文档

  -d
  --delete
  Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if 
  no upstream was set with --track or --set-upstream-to.

  -D
  Shortcut for --delete --force.


您的情况应该是


In your case, it should be,

  git branch -d feature/search

这篇关于如何仅从本地git删除远程分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆