I'm trying to automate a very periodic git add/commit/push cycle using a shell script and cron under OS X 10.8.5. The script is as basic as one would expect it to be:

cd /my/directory
git add .
git commit -m "a commit message with the date"
git push -u origin master

I've tried running it both as root as well as a non-root user. When I do this manually, I get a dialog box from OS X requesting that I authenticate the operation.

Running the script (either using cron or just using sh) ends up sending a message (via mail) to whichever user's cron executed the script saying that it was unable to write a file in the .git directory because of a permissions issue (which is most likely manual execution requires authentication).

Is there any way to circumvent this issue, or give the script permission to perform this operation without having me intervene each time?


First, make sure your git directory is somewhere where you have full read/write access. If you have to, chmod -R 777 /my/directory

Then, use gitbash with ssh key to generate a secure path for future connections

Then, try your script again

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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