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.
Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands. Using Git aliases will make you a faster and more efficient developer. Aliases can be used to wrap a sequence of Git commands into new faux Git command.
That means the Git status is normal. As soon as you start editing a file, the status changes to modified and the icon overlay then changes to a red exclamation mark. That way you can easily see which files were changed since you last updated your working tree and need to be committed.
The "commit" command is used to save your changes to the local repository. Note that you have to explicitly tell Git which changes you want to include in a commit before running the "git commit" command. This means that a file won't be automatically included in the next commit just because it was changed.
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn't really affect the repository in any significant way—changes are not actually recorded until you run git commit .
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" ...
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