Kex*_*Kex 5 git macos bash cron
嘿,我正在尝试使用 Mac 上的 cron 作业将代码推送到 git。我使用编辑 crontabcrontab -e并在其中包含以下内容:
* 12 * * 1 ~/Dropbox/MD/sync.sh
* 12 * * 5 ~/Dropbox/MD/sync.sh
Run Code Online (Sandbox Code Playgroud)
脚本如下:
#!/bin/bash
cd ~/Dropbox/MD
/usr/bin/git add .
/usr/bin/git commit -m "Docs auto update"
/usr/bin/git push origin master
Run Code Online (Sandbox Code Playgroud)
但是该命令失败,当我运行时,mail我可以检查错误消息:fatal: could not read Username for 'https://github.com': Device not configured。我该如何解决这个问题?如果我从终端手动运行命令,则不会出现任何问题,也不会提示我输入用户凭据。
对此的任何指示将不胜感激。谢谢!
当自动执行 git 任务时,建议使用 SSH 密钥。您可以按照以下步骤设置具有推送访问权限的 SSH 密钥:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com":)cat ~/.ssh/id_rsa.pub)Deploy Keys(https://github.com/user/project/settings/keys)Allow write accessAdd Key请注意,这仅适用于使用以下远程克隆的存储库:git@github.com:user/project.git
可以通过以下步骤更新遥控器:
git remote remove origingit remote add origin git@github.user/project.git| 归档时间: |
|
| 查看次数: |
7119 次 |
| 最近记录: |