强制删除 Git 中的一个分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41379997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:43:15  来源:igfitidea点击:

Force-delete a branch in Git?

gitgit-branch

提问by Aditi Yadav

I have created a branch testin my Git repository. Now I have no use for it. How can I force-delete this branch?

test在我的 Git 存储库中创建了一个分支。现在我没有用了。如何强制删除此分支?

I tried the following command:

我尝试了以下命令:

git branch -d test

But it returns an error.

但它返回一个错误。

回答by Brijesh

You can force-delete a branch with the following command:

您可以使用以下命令强制删除分支:

git branch -D test

By replacing -dwith -D, you are telling git to delete the branch and that you don't care to merge changes from that branch.

通过替换-d-D,您是在告诉 git 删除该分支,并且您不关心合并来自该分支的更改。

Be careful, you can lose data.

小心,您可能会丢失数据。