Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git commit exclamation results in zsh: illegal modifier:

Tags:

git

commit

zsh

I'm running the latest available stable version of Zsh and am running into an error using a ! exclamation mark in a git commit message, following conventional commit style. https://www.conventionalcommits.org/en/v1.0.0/

→ zsh --version
zsh 5.8 (x86_64-apple-darwin19.3.0)

And the zsh-offending commit message:

→ git commit -am "chore(foo)!: bar"    
zsh: illegal modifier:

I've tried the same command in Bash, Fish, and Hyper and all succeed without issue. So this appears to be another wonky Zsh nuance. Does anyone have a fix for zsh? I'd really like to be able to use the -am shorthand rather than having to go into the full git commit interactive editor.

like image 668
shellscape Avatar asked Feb 04 '26 20:02

shellscape


1 Answers

zsh interprets the ! as the beginning of a history expansion. Just use single quotes instead of double quotes.

git commit -am 'chore(foo)!: bar'
like image 200
chepner Avatar answered Feb 07 '26 08:02

chepner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!