Windows计划任务git推送到github

Pok*_*com 6 windows git github msysgit

我希望每天晚上都可以添加一个Windows Scheduled Task来git push to github.我有一个CMD文件.当我在Windows命令提示符下运行CMD文件时,它工作正常.但是,当我通过Windows计划任务运行它.它永远停滞不前.状态为"正在运行".从日志中我可以看到它成功启动了git bash shell.任何的想法?

echo git push > i:\gitpush
echo 'pushing' >>log1
C:\WINDOWS\SysWOW64\cmd.exe  /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login i:\gitpush" >>log1 2>>error    
echo 'done pushing' >>log1
del i:\gitpush
Run Code Online (Sandbox Code Playgroud)

这是日志输出:

'pushing'
Welcome to Git (version 1.7.4-preview20110204)


Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
Run Code Online (Sandbox Code Playgroud)

然后我做了一个实验,将gitpush脚本重命名为错误的文件名.它会立即退出并出现错误"没有这样的文件或目录",这是预期的.它显示gitpush脚本正确传递给bash但由于某种原因它被卡住了.

我必须通过git bash shell的原因是因为我不知道如何在不使用git bash shell的情况下在windows命令行shell中设置公钥.

谢谢!

Von*_*onC 3

我不知道如何在 Windows 命令行 shell 中设置公钥

公钥/私钥也可以在 DOS shell 中使用,前提是您定义了%HOME%环境变量(引用 的父目录.ssh

Windows 计划任务的技巧是确保:

  • 在实际运行该任务(“系统帐户”?或实际用户?)
    显示“env ”可以帮助调试问题。
  • 在哪里运行:如果 git push 依赖于当前路径来正确推送当前存储库,则需要确保您的任务在应该运行的位置运行。