git别名删除分支机构没有警告

发布于 2025-01-17 22:07:48 字数 348 浏览 1 评论 0原文

在尝试删除尚未合并的git分支时,例如git分支-d my -feature

error: The branch 'my-feature' is not fully merged.
If you are sure you want to delete it, run 'git branch -D my-feature'.

当我在〜/中有GIT Alias时, 我会收到警告。 。

[alias]
    bd = branch -d

这是预期的行为吗?它与别名的使用有关系吗?

When trying to delete a git branch that has not been merged, such as git branch -d my-feature, I would get a warning

error: The branch 'my-feature' is not fully merged.
If you are sure you want to delete it, run 'git branch -D my-feature'.

However, when I have a git alias in my ~/.gitconfig

[alias]
    bd = branch -d

and then do git bd my-feature, git has no problem deleting the branch without a warning.

Is this the expected behavior? Does it have anything to do with the use of the alias?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水微香 2025-01-24 22:07:48

我找出了问题的原因。在 git 别名列表中,除了 bd =branch -d 之外,我还无意中包含了 bD=branch-D ,这会强制删除分支。我猜 git 别名不区分大小写,因此它匹配第二个别名而不是第一个。

I figured out the cause of my problem. In the list of git aliases, in addition to bd = branch -d, some lines further down I had inadvertently included bD = branch -D, which force-delete the branch. I guess git aliases are case-insensitive, so it matches the second alias instead of the first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文