git别名删除分支机构没有警告
在尝试删除尚未合并的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找出了问题的原因。在 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 includedbD = branch -D
, which force-delete the branch. I guess git aliases are case-insensitive, so it matches the second alias instead of the first.