【发布时间】:2020-03-09 07:58:42
【问题描述】:
我需要遵循以# 开头的 git commit 消息格式(例如#1234 ...)。
这不是与Start a git commit message with a hashmark (#) 重复,因为我知道commentchar 并且我已经将git 配置为使用不同的评论字符:
gino@myrepo$ git config --global --get core.commentchar
;
gino@myrepo$ git config --get core.commentchar
;
我还确认,如果我从命令行提交,它可以工作:
gino@myrepo$ git log
Author: ...
Date: Wed Nov 13 21:59:40 2019 +0900
# Test `git commit` from terminal
# These 2 lines should not be treated as comments
问题是当我尝试从VS Code's Commit UI 提交时:
VS Code 的 Git 似乎不支持 # 不是注释的配置,因为当我检查 git log 时,它只显示第 2 行:
gino@myrepo$ git log
commit 1254416d309588293372b96fd1f71e30af51b1fe (HEAD -> master)
Author: ...
Date: Wed Nov 13 22:23:17 2019 +0900
These lines should be details.
当我尝试使用单行消息 (#4567: blah) 时,情况更糟。提交 UI 不允许我提交(单击提交按钮时没有任何反应)并且 Command Palette > Git: Commit 命令将简单地中止提交(可能因为它被视为空提交消息)。
如何让 VS Code 识别自定义 commentchar 设置?
注意事项:
- 我知道 VS Code 使用我的
git config(全局或本地),因为当我尝试更改其他设置(例如user.name)时,它会正确应用它 - 它不是 Start a git commit message with a hashmark (#) 的重复,因为我说的是通过 VS Code 的 Commit UI,而不是通过命令行提交
- 我找不到 VS Code > 与提交消息相关的 Git 设置
- 我正在使用 VS Code 1.40.0
【问题讨论】:
-
你试过用反斜杠
\#转义它吗?不确定这是否可行。 -
@Bauke:好吧,
#-line 行出现了,但提交消息变成了\#...,这也不正确。 -
我发现 this issue 似乎有你想要修复的东西。不过我不知道什么时候可以使用。
-
@Philippe, @phd:不,这不是重复的,因为正如我在文章开头所解释的那样,我知道如何通过命令行进行操作(使用 @987654343 @ git config)并且我已经确认它正在工作。我的实际问题(我在帖子的其余部分和标题中描述了与通过 VS Code 的源代码控制 UI 执行相同操作有关,这似乎不尊重
commentchar配置。
标签: git visual-studio-code vscode-settings git-commit