【问题标题】:Problem with a script that pushes automatically自动推送的脚本有问题
【发布时间】:2020-08-01 13:44:33
【问题描述】:

我想用git来备份一些重要的数据。为此,我制作了这个脚本(使用 ssh 进行身份验证,因此不需要插入我的凭据)。

cd /media/patrick/Data
/usr/bin/inotifywait -m /media/patrick/Data -e create -e move -e modify -e delete |
   while read path action file; do
       git add *
       git commit -m ‘”$(date)” file “$file” appeared in the directory “$path”  via “$action”’
       git push -u origin master
   done

但这不起作用,似乎 git 试图添加提交消息中的内容。 我收到此错误:

error: pathspec '31' did not match any file(s) known to git
error: pathspec 'Jul' did not match any file(s) known to git
error: pathspec '2020' did not match any file(s) known to git
error: pathspec '07:57:58' did not match any file(s) known to git
error: pathspec 'PM' did not match any file(s) known to git
error: pathspec 'CEST”' did not match any file(s) known to git
error: pathspec 'file' did not match any file(s) known to git
error: pathspec '“test”' did not match any file(s) known to git
error: pathspec 'in' did not match any file(s) known to git
error: pathspec 'the' did not match any file(s) known to git
error: pathspec 'directory' did not match any file(s) known to git
error: pathspec '“/media/patrick/Data/”' did not match any file(s) known to git
error: pathspec 'modified/created/removed' did not match any file(s) known to git
error: pathspec 'via' did not match any file(s) known to git
error: pathspec '“MOVED_FROM”’' did not match any file(s) known to git
Branch 'master' set up to track remote branch 'master' from 'origin'.
Everything up-to-date

不知道原因,对不起,我不习惯壳。谢谢。

【问题讨论】:

    标签: bash git github


    【解决方案1】:

    如果你想在提交消息中使用引号,你的提交消息应该用引号引起来,你必须将它们转义:

    git commit -m "\"$(date)\" file \"$file\" appeared in the directory \"$path\" via \"$actionv\"" 
    

    【讨论】:

      猜你喜欢
      • 2015-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-02
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多