通过命令行在Git提交消息中使用感叹号 [英] Use of an exclamation mark in a Git commit message via the command line

查看:248
本文介绍了通过命令行在Git提交消息中使用感叹号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从命令行在Git提交消息中输入感叹号?

How do I enter an exclamation point into a Git commit message from the command line?

可以用反斜杠转义感叹号,但是反斜杠最终也会出现在提交消息中.

It is possible to escape the exclamation point with a backslash, but then the backslash ends up in the commit message as well.

我想要这样的东西:

git commit -am "Nailed it!"

推荐答案

使用单引号而不是双引号

Use single quotes instead of double quotes

git commit -am 'Nailed it!'

或者,如果出于某种原因需要使用双引号,但仍然需要文字!,则可以通过set +H

Alternatively, if you need to use double quotes for whatever reason but still want a literal ! then turn off history expansion at the top of your script via set +H

这篇关于通过命令行在Git提交消息中使用感叹号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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