Passing all parameters to a git alias

bash, git

Solution

You need to quote the embedded doublequotes.

cii = "!f() { git commit \"$@\"; }; f"

git will then perform standard shell expansion of `"$@"` which translates to a single word for each parameter - like `"$1" "$2" "$3" ...`

Problem

To simplify my concern, I narrowed it to the following: I have a GIT alias defined as such: ``` cii = "!f() { git commit "$@"; }; f" ``` When I run ``` $ git cii -m "test1" ``` It works fine, but it fails with ``` $ git cii -m "test1 and test2" error: pathspec 'and' did not match any file(s) known to git. error: pathspec 'test2' did not match any file(s) known to git. ``` Any idea ? Note that my real alias is much more complex that the above, so responding with cii = "commit" is not an option. The point here is passing the input parameters to the function.

Original source