Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitconfig [alias] doesn't recognize strings

I am trying to make an alias for my GIT that looks something like that:

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

This alias is for minor modifications that do not need any message. The problem is that whenever I run git send it returns the following:

$ 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 run the command manually there is 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?

like image 918
RafazZ Avatar asked Oct 21 '25 04:10

RafazZ


1 Answers

As per git-config(1), under CONFIGURATION FILE: Syntax:

String values may be entirely or partially enclosed in double quotes. You need to enclose variable values in double quotes if you want to preserve leading or trailing whitespace, or if the variable value contains comment characters (i.e. it contains # or ;). Double quote " and backslash \ characters in variable values must be escaped: use \" for " and \\ for \.

You don’t strictly have to add a second set of quotes, so:

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

Also, if you save your aliases using git config, you can avoid having to do the escaping manually:

$ git config --global \
    alias.send '!git add . && git commit -m "AUTOCOMMIT: $(date)" && git push'
like image 50
Ry- Avatar answered Oct 22 '25 17:10

Ry-