Can't add the “!” symbol in my git commit message
How do I enter an exclamation point into a git commit message from the command line?
I’m new to git, and I did this command:
git commit -m "First Commit!"
This throws an error like this:
bash: !": event not found
Why is this error happening? Is is that in Git, I shouldn’t use
! symbols in
Are there other symbols which I shouldn’t use or should escape with any escape sequence?
3 Solutions collect form web for “Can't add the “!” symbol in my git commit message”
Nothing to do with git, more to do with bash – escape the
! or use single quotes, i.e.
$ git commit -m "First Commit\!"
$ git commit -m 'First Commit!'
That’s not git related at all, but bash related. Using ! in a string will cause bash to attempt history expansion. If you don’t want that, either use single-quoted strings or escape the exclamation mark with a backslash.
No, this is possible in with the git command line and double quotes. One easy fix is putting a space after
git commit -m "First Commit! "
Another way to get around this is by using
git gui or just
git commit and then specifying the message in the editor that opens.
The limitation is clearly a bash limitation and not a problem of git. You can avoid it using single quotes:
git commit -m 'First Commit!'