Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use git push in a bash script being run by crontab to push a commit to github. At the end of the script I'm doing this:

# script processes some files, then:
git add -A
git commit -a -m "Updated $(date)"
git push origin master

The add and commit work fine (and the push works fine when running the script from the CL, not using cron), but I get errors on the push to github with cron:

git: 'credential-osxkeychain' is not a git command. See 'git --help'.
fatal: could not read Username for '': Device not configured

I've searched through other threads (like this, and this), but it doesn't appear to be an issue with SSH (at least I tried passing SSH_AUTH_SOCK environment variable in the crontab line and that didn't work). Running OSX 10.8.

Any ideas?

share|improve this question
up vote 4 down vote accepted

Thanks to the support team at GitHub I was able to solve this.

The first problem was that git-credential-osxkeychain was not in my path when the cron job ran. For me, git and git-credential-osxkeychain were both being run out of the Xcode command line tools directory:

$ which git
$ which git-credential-osxkeychain

When running which git from cron, turns out cron was running git from /usr/bin.

I added the appropriate directory to my PATH at the top of the cron job with:

export PATH=$PATH:/Applications/

That solved the git: 'credential-osxkeychain' is not a git command error, but I got yet another error:

fatal: could not read Username for '': Device not configured

At the suggestion of the GitHub support team, I solved the problem (without the need for git-credential-osxkeychain at all) by authenticating via SSH instead of https:

git remote set-url origin

TL;DR? Solved problems with git push via cron by using SSH instead of HTTPS.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.