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

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

问题描述

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

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

$ git branch -D <branch_name>

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

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"是强制删除选项.
  • 我要删除本地分支,并将远程分支保留在原始位置.
  • "-D" is force delete option.
  • I want delete the local branch and keep the remote branch in origin.

推荐答案

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天全站免登陆