.gitconfig [alias] does not recognize lines

I'm trying to make an alias for my GIT that looks something like this:

[alias]
    send = !git add . && git commit -m "AUTOCOMMIT: $(date)" && git push

      

This alias is for minor changes that don't need any communication. The problem is that whenever I run git send

it returns this:

$ git send
error: pathspec 'Fri' did not match any file(s) known to git.
error: pathspec 'Aug' did not match any file(s) known to git.
error: pathspec '22' did not match any file(s) known to git.
error: pathspec '11:31:18' did not match any file(s) known to git.
error: pathspec 'PDT' did not match any file(s) known to git.
error: pathspec '2014' did not match any file(s) known to git.

      

If I ran the command manually, there was no error:

$ git add .
$ git commit -m "AUTOCOMMIT: $(date)"
[master] AUTOCOMMIT: Fri Aug 22 11:37:17 PDT 2014
 1 file changed, 1 deletion(-)
$ git push
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 368 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To <gitRepo>.git
   master -> master

      

Any ideas?

+3


source to share


2 answers


As per git-config(1)

, under CONFIGURATION FILE: Syntax :

String values ​​can be fully or partially enclosed in double quotes. You need to enclose variable values ​​in double quotes if you want to preserve leading or trailing spaces, or if the value variable contains comment characters (i.e. contains #

or ;

). double quote "

and backslashes \

in variable values ​​must be escaped: use \"

for "

and \\

for \

.

You don't need to add the second set of quotes, so:



[alias]
    send = !git add . && git commit -m \"AUTOCOMMIT: $(date)\" && git push

      

Also, if you store your aliases with git config

, you can avoid having to do escaping manually:

$ git config --global \
    alias.send '!git add . && git commit -m "AUTOCOMMIT: $(date)" && git push'

      

+4


source


Solved it by changing the alias:

[alias]
    send = !git add . && git commit -m "\"AUTOCOMMIT: $(date)\"" && git push

      



The question still exists: Why should I avoid ""

? I expected the whole line to be executed by the shell only.

0


source







All Articles