Raf*_*azZ 3 git alias git-config
我正在尝试为我的GIT创建一个看起来像这样的别名:
[alias]
send = !git add . && git commit -m "AUTOCOMMIT: $(date)" && git push
Run Code Online (Sandbox Code Playgroud)
此别名适用于不需要任何消息的微小修改.问题是每当我运行git send它时返回以下内容:
$ 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.
Run Code Online (Sandbox Code Playgroud)
如果我手动运行该命令,则没有错误:
$ 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
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
根据git-config(1),在CONFIGURATION FILE下:语法:
字符串值可以完全或部分用双引号括起来.如果要保留前导或尾随空格,或者变量值包含注释字符(即它包含
#或;),则需要将变量值括在双引号中.必须转义变量值中的双引号"和反斜杠\字符:use\"for"和\\for\.
您不必严格添加第二组引号,因此:
[alias]
send = !git add . && git commit -m \"AUTOCOMMIT: $(date)\" && git push
Run Code Online (Sandbox Code Playgroud)
此外,如果使用保存别名git config,则可以避免必须手动转义:
$ git config --global \
alias.send '!git add . && git commit -m "AUTOCOMMIT: $(date)" && git push'
Run Code Online (Sandbox Code Playgroud)