Windows定时任务git推送到github
我希望添加一个Windows计划任务每天晚上git推送到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
这是日志输出:
'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.
然后我做了一个实验,将 gitpush 脚本重命名为错误的文件名。它立即退出并出现错误“没有这样的文件或目录”,这是预期的。它显示 gitpush 脚本已正确传递到 bash,但由于某种原因它被卡住了。
我必须通过 git bash shell 的原因是因为我不知道如何在不使用 git bash shell 的情况下在 Windows 命令行 shell 中设置公钥。
谢谢!
I hope to add a Windows Scheduled Task to git push to github every night. I have a CMD file. When I run the CMD file on the windows command prompt, it works fine. But when I run it via windows scheduled task. It's stuck forever. The status is "running". And from the log I can see it successfully started the git bash shell. Any idea?
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
Here is the log output:
'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.
Then I did an experiment to rename gitpush script to a wrong file name. And it exited immediately with the error "No such file or directory", which is expected. It shows the gitpush script is passing in correctly to the bash but for some reason it's stuck.
The reason I have to go through git bash shell is because I don't know how to setup public key in windows command line shell without using git bash shell.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
公钥/私钥也可以在 DOS shell 中使用,前提是您定义了
%HOME%
环境变量(引用%HOME%
的父目录) code>.ssh)Windows 计划任务的技巧是确保:
显示“
env
”可以帮助调试问题。Public/private keys work also in a DOS shell, provided you define the
%HOME%
environment variable (referencing the parent directory of the.ssh
)The trick with Windows Scheduled Task is to make sure:
Displaying "
env
" can help debugging the issue.