使用井号 (#) 开始 git commit 消息 [英] Start a git commit message with a hashmark (#)
问题描述
Git 在提交时将以 #
开头的行作为注释行.这在使用票证跟踪系统时非常烦人,并试图在行首写入票号,例如
Git treats lines starting with #
as comment lines when committing. this is very annoying when working with a ticket tracking system, and trying to write the ticket number at the beginning of the line, e.g.
#123 salt hashed passwords
git 将简单地从提交消息中删除该行.有没有办法逃避哈希?我尝试了 和
!
,但没有任何效果.#
之前的空格被保留,因此它们也不是问题的有效解决方案.
git will simply remove the line from the commit message. is there any way to escape the hash? i tried and
!
, but nothing works. whitespaces before #
are preserved, so they aren't a working solution to the problem either.
推荐答案
此行为是 git commit
的默认清理"行为的一部分.如果您想保留以 #
开头的行,您可以使用替代清理模式.
This behaviour is part of git commit
's default 'clean-up' behaviour. If you want to keep lines starting with #
you can use an alternative clean-up mode.
例如
git commit --cleanup=whitespace
如果你这样做,你必须小心地删除所有你不想出现在提交中的 #
行.
If you do this you have to be careful to remove all #
lines that you don't want to appear in the commit.
这篇关于使用井号 (#) 开始 git commit 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!