I can't find any examples of git alias's that allow arguments with spaces, here is what I have created:
cax = "!f() { msg=${1-Default message}; git add --all && git commit -am "$msg"; }; f"
This works fine with:
git cax "one-word"
But breaks with:
git cax "one word"
Thanks!
Did you notice the odd syntax highlighting in your question?
cax = "!f() { msg=${1-Default message}; git add --all && git commit -am "$msg"; }; f"
^^^^^^ ^^^^ black
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ red
That should have been a big hint. The problem is that $msg isn't quoted in your function definition. " characters are treated specially by Git when it is reading your config file, but you want to pass these two characters to the shell. Use \"$msg\" instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With