删除本地分支机构的危急情况 [英] Critical situation in removing a local branch

查看:17
本文介绍了删除本地分支机构的危急情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下命令通过 force delete 选项删除本地分支:

I'm using the following command to remove a local branch with force delete option:

$ git branch -D <branch_name>

我的问题是,如果我删除设置了 upstream本地分支,然后进行正常推送,它不会删除 远程分支 对吗?

My question is, If I delete a local branch that had an upstream set and then do a normal push, it won't delete the remote branch right?

在这种情况下我该怎么办?

What should I do in this situation?

[注意]:

  • -D" 是强制删除选项.
  • 我想删除本地分支并将远程分支保留在原点.

推荐答案

git 只会删除你的本地分支,请记住,本地和远程分支实际上是没有任何关系的.它们在 Git 中是完全独立的对象.

git will only delete your local branch, please keep in mind that local and remote branches actually have nothing to do with each other. They are completely separate objects in Git.

即使您已经建立了跟踪连接(在大多数情况下都应该这样做),但这并不意味着删除一个也会删除另一个!

Even if you've established a tracking connection (which you should for most scenarios), this still does not mean that deleting one would delete the other, too!

如果要删除任何分支项,则需要显式删除它.

If you want any branch item to be deleted, you need to delete it explicitly.

在 Git 中删除本地分支

git branch -d <branch_name>

使用大写的-D 就像-d 的强制"版本.如果分支没有完全合并,如果你使用小写版本,你会得到一个错误.这再次与远程分支无关,只会删除您的本地分支.

using a capital -D is like a "force" version of -d. If the branch isn't fully merged you'll get an error if you use the lowercase version. This again has no relevance to the remote branches and will only delete your local branch.

在 Git 中删除远程分支

git push origin --delete <branch_name>

所以你的问题

如果我删除了一个设置了上游的本地分支,然后执行正常推送,不会删除远程分支吧?

If I delete a local branch that had an upstream set and then do a normal push, it won't delete the remote branch right?

你是对的,它不会删除远程分支.

You are correct it will not delete the remote branch.

这篇关于删除本地分支机构的危急情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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