I just observed having ! before a git commit message triggers events in zsh.
Not sure if it's zsh issue or git feature. Please explain.
I just observed having ! before a git commit message triggers events in zsh.
Not sure if it's zsh issue or git feature. Please explain.
This is unrelated to git, your shell is trying to expand the !.
Use either \! to escape the character or 'single quotes' instead of "double quotes" to disable the shell's variable/history expansion within the string.
To learn more about your shell's history expansion, have a look at zsh's User Guide - 3.6.1: History expansion
The simplest use-case for it is re-running a command with sudo !! after forgetting to specify sudo at the beginning.
Side-note with regards to git commit:
I strongly recommend against using -m when committing, because it takes away the chance to notice something being wrong with the commit.
If you don't use -m the text editor for message input will have a list of staged/unstaged changes. It's always a good idea to have a short look at those lists before finalizing the commit.
(If you notice something is wrong, just save with empty message and the commit will be aborted)
That seems to be the case for bash as well.
Try and escape that character to avoid any shell-related side-effect:
git commit -m "add \!empty check"
# or
git commit -m 'add !empty check'
(see jthill's comment on single quotes)
Or turn off history substitution using set +H.