问题描述
我想使用cron作业提交一些文件更改,调用脚本中的以下行在根crontab
0 * * * * cd / files /&& ./backup.sh> / tmp / cronlog 2> / tmp / cronerror
如下:
#!/ usr / bin / env bash
...准备备份文件...
echocommit changes ...
git add -u
git commit -mbackup
git push
在cron设置之前,我还设置了 user.email
和<$ c $
但是对于root用户,我已经检查了脚本是否运行了c> user.name / tmp / cronerror
我收到以下众所周知的消息。
***请告诉我你是谁。
运行
git config --global [email protected]
git config --global user.nameYour Name
设置您的帐户的默认身份。
...
我也尝试过设置 HOME = / root
有没有办法告诉git命令在哪里可以找到全局变量
我的解决方案是使用 git config ... / code>不带
- 全局
选项,将配置存储在当前存储库中,git能够找到它。
I want to commit some file changes using a cron job calling a script with the following line in roots crontab
0 * * * * cd /files/ && ./backup.sh >/tmp/cronlog 2>/tmp/cronerror
the script looks as follows:
#!/usr/bin/env bash
… prepare the files for the backup …
echo "commit changes …"
git add -u
git commit -m "backup"
git push
Prior to the cron setup I've also set user.email
and user.name
for the root user and I've checked that the script runs if I call if from the command line.
But in /tmp/cronerror
I receive the following well known message.
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
…
I've also tried setting HOME=/root
in the script but this doesn't seam to make a difference.
Is there a way of telling the git command where to find the global git-config when running in a cron job?
My solution is to use git config …
without --global
option which stores the configuration in the current repository, where git is able to find it.
这篇关于git commit无法找到(全局)配置在cron作业中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!