0

In my ~/.gitconfig, I have something like

[alias]
    ac = !git add --all && git commit -m
    mileung = !git add --all && git commit --author="MyUserName <my@email.com>" -m

Running git ac "message" works, but running git mileung "another message" yields git add --all && git commit --author=MyUserName <my@email.com> -m: my@email.com: No such file or directory

sdfsdf
  • 5,052
  • 9
  • 42
  • 75

1 Answers1

2

When Git reads configuration file lines, it uses double quotes to quote text, to avoid specially interpreting the characters. The result is that after this parsing your alias reads:

!git add --all && git commit --author=MyUserName <my@email.com> -m

which is a slightly odd spacing and minor re-arrangement of:

!git add --all && git commit --author=MyUserName < my@email.com > -m

which tells the shell to direct the git commit command's input from the file my@email.com and write its output to the file -m.

You can either escape the quotes here, or use a different kind of quote as bimlas suggested in a comment:

mileung = !git add --all && git commit --author=\"MyUserName <my@email.com>\" -m

(this version keeps Git from eating the double quotes, so that the shell sees them and the shell eats them instead while also protecting the angle brackets and spaces), or:

mileung = !git add --all && git commit --author='MyUserName <my@email.com>' -m

(here Git does not eat single quotes, so the shell sees the single quotes, uses them to quote the angle brackets and spaces, and then eats the single quotes).

(This problem is not at all unique to Git; see, e.g., Trouble escaping quotes in a shell script.)

torek
  • 448,244
  • 59
  • 642
  • 775