在git提交消息中转义注释字符(#) [英] Escape comment character (#) in git commit message

查看:754
本文介绍了在git提交消息中转义注释字符(#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将mcedit设置为git提交消息的编辑器。默认情况下,它将忽略以字符开头的任何行。不过奇怪的是,我可以看到我的提交信息如下:

 #FOO-123:实施吧foo 

提交正在进行的工作

#FOO-123:... 实际上是我们跟踪器中问题的关键+标题。跟踪器可以自动接收这些提交消息并将其添加到该问题。



不幸的是,第一行被视为一个注释,被忽略。



我不想通过添加 -m 从命令行提交,因为当你有多个



我如何解决这个问题?

解决方案

你可以尝试在提交消息中为评论定义一个不同的字符:

  git config core.commentchar< another char> 

正如我在启动带有哈希标记(的git提交消息,此设置自git 1.8.2(2013年2月)起可用。 p>

在你的情况下:

  git config core.commentchar*

请注意,您在理论上可以放置一个core.commentchar字(多个字符),但git 2.0.x / 2.1将更严格。



请参阅提交50b54fd NguyễnTháiNgọcDuy( pclouds



配置:在core.commentChar上严格




我们不支持注释字符串(至少尚未)。多字节字符编码也可能被误解。



使用两个逗号进行测试,因为它违反了这一点。它添加了补丁,引入 core.commentChar in eff80a9 (允许自定义comment char - 2013-01-16)。我不清楚为什么需要这种行为。







poke 还提到在评论中更改提交模板


编辑提交信息时,启动编辑器中的内容给定文件。

通常使用 commit.template 配置变量来隐式地给这个命令。 p>


I have set mcedit as my editor for git commit messages. By default it ignores any lines starting with the # character. However odd this may seem, I need to be able to have the my commit message looking like this:

#FOO-123: Implement bar foo

Committing work in progress

The #FOO-123: ... is actually the key + title of an issue in our tracker. The tracker can automatically pick up these commit messages and add them to the issue.

Unfortunately, the first line gets treated like a comment and gets ignored.

I don't want to have to be committing from the command line by adding -m as it's inconvenient/ugly when you have multiple lines.

How could I work around this?

解决方案

You can try and define a different character for comments in commit message:

git config core.commentchar <another char>

As I mention in "Start a git commit message with a hashmark (#)", this setting is available since git 1.8.2 (February 2013).

In your case:

git config core.commentchar "*"

Note that you could in theory put a core.commentchar word (multiple characters), but git 2.0.x/2.1 will be stricter.

See commit 50b54fd by Nguyễn Thái Ngọc Duy (pclouds):

config: be strict on core.commentChar

We don't support comment strings (at least not yet). And multi-byte character encoding could also be misinterpreted.

The test with two commas is updated because it violates this. It's added with the patch that introduces core.commentChar in eff80a9 (Allow custom "comment char" - 2013-01-16). It's not clear to me why that behavior is wanted.


poke also mentions in the comments to change the commit template:

When editing the commit message, start the editor with the contents in the given file.
The commit.template configuration variable is often used to give this option implicitly to the command.

这篇关于在git提交消息中转义注释字符(#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆