Git commit cannot find (global) configuration in cron work

I want to make some file changes using a cron job invoking a script with the following line in the roots of crontab

0 * * * * cd /files/ && ./backup.sh >/tmp/cronlog 2>/tmp/cronerror 

The script looks like this:

 #!/usr/bin/env bash … prepare the files for the backup … echo "commit changes …" git add -u git commit -m "backup" git push 

Before installing cron, I also set user.email and user.name for the root user, and I checked that the script runs if I call if from the command line.

But in /tmp/cronerror I get the following well-known message.

 *** Please tell me who you are. Run git config --global user.email " you@example.com " git config --global user.name "Your Name" to set your account default identity. … 

I also tried setting HOME=/root to the script, but this is not a seam to make a difference.

Is there a way to tell the git command where to find the global git-config when working in a cron job?

+1
git git-commit cron
source share
1 answer

My solution is to use git config … without --global , which saves the configuration in the current repository, where git can find it.

+1
source share

All Articles