kni*_*ttl 266 git ticket-system commit ticket-tracking
Git #在提交时处理以注释行开头的行.这在使用票证跟踪系统时非常烦人,并且试图在该行的开头写入票号,例如
#123 salt hashed passwords
Run Code Online (Sandbox Code Playgroud)
git将简单地从提交消息中删除该行.有没有办法逃脱哈希?我试过\和!,但没有任何工程.之前#的空白被保留,因此它们也不是解决问题的有效方法.
CB *_*ley 220
此行为是git commit默认"清理"行为的一部分.如果您想保持行开头,#可以使用其他清理模式.
例如
git commit --cleanup=whitespace
Run Code Online (Sandbox Code Playgroud)
如果这样做,则必须小心删除#不希望出现在提交中的所有行.
Von*_*onC 129
请注意,从git1.8.2(2013年2月)开始,您可以#在提交消息中为注释行使用与' ' 不同的字符.
这允许您使用' #'作为您的错误号参考.
Git在要求用户编辑编辑器中的消息时提供的各种"提示"行
#默认情况下用' ' 注释掉.所述
core.commentChar配置变量可以被用于定制这个"#"为不同的字符.
从理论上讲,你可以说一个core.commentChar单词(多个字符),但git 2.0.x/2.1会更严格(2014年第3季度).
我们不支持评论字符串(至少尚未支持).并且多字节字符编码也可能被误解.
使用两个逗号的测试会更新,因为它违反了此规则.它添加了
core.commentChar在eff80a9中引入的补丁(允许自定义"评论字符" - 2013-01-16).我不清楚为什么要采取这种行为.
git 2.0.x/2.1(2014年第3季度)将为以下内容添加自动选择core.commentChar:
请参阅提交84c9dc2
当
core.commentChar为"auto"时,注释char以'#'默认开头,但如果它已经在准备好的消息中,则在一个小子集中找到另一个char.这应该可以阻止意外,因为git意外地剥离了一些行.请注意,git不够智能,无法将'
#' 识别为自定义模板中的注释字符,并在最终注释字符不同时进行转换.
它将自定义模板中的"#"行视为提交消息的一部分.所以不要将它与自定义模板一起使用.
"auto"的候选字符列表是:
# ; @ ! $ % ^ & | :
Run Code Online (Sandbox Code Playgroud)
这意味着一个命令git commit -m '#1 fixed issue'会自动将commentChar切换为' ;',因为' #'在提交消息中使用了' '.
Mat*_*oli 75
这里的答案是好的和详细的,但对于像我这样的git noob定制git配置选项并不是那么明显.这里是从变化的示例#,以;用于注释字符:
git config core.commentChar ";"
Run Code Online (Sandbox Code Playgroud)
这就是你需要做的.
Oli*_*ier 61
您可以使用命令行选项-m:
git commit -m "#123 fixed"
Run Code Online (Sandbox Code Playgroud)
Owa*_*ams 30
如果你正在进行交互式rebase,那么当你保存提交消息时没有任何内容(因为#开头已经使它成为注释,因此它被忽略了)git将告诉你该怎么做:
Aborting commit due to empty commit message.
Could not amend commit after successfully picking 5e9159d9ce3a5c3c87a4fb7932fda4e53c7891db... 123 salt hashed passwords
This is most likely due to an empty commit message, or the pre-commit hook
failed. If the pre-commit hook failed, you may need to resolve the issue before
you are able to reword the commit.
You can amend the commit now, with
git commit --amend
Once you are satisfied with your changes, run
git rebase --continue
Run Code Online (Sandbox Code Playgroud)
所以,只需修改消息:
git commit --amend -m "#123 salt hashed passwords"
Run Code Online (Sandbox Code Playgroud)
继续坚持:
git rebase --continue
Run Code Online (Sandbox Code Playgroud)
Sun*_*gam 25
git commit --cleanup=scissors应该使用.它已添加到2014.05.21的Git v2.0.0中
从 git commit --help
--cleanup=<mode>
scissors
Same as whitespace, except that everything from (and including) the line
"# ------------------------ >8 ------------------------" is truncated if the message
is to be edited. "#" can be customized with core.commentChar.
Run Code Online (Sandbox Code Playgroud)
hel*_*ete 10
只需在字符 之前使用空格字符来开始提交消息即可#。
然后git停止将该行视为注释,并且github可以毫无问题地使用散列票号。
vim的默认语法突出显示甚至通过将颜色从评论性更改为内容性来暗示该功能。
| 归档时间: |
|
| 查看次数: |
48922 次 |
| 最近记录: |