Eastern Monk Eastern Monk - 4 months ago 18
Bash Question

How to setup a Cron job to do a Git commit

I have been manually committing my git repository everyday. But then sometimes I forget.

Is it possible to write a shell script to do a git commit ?

I am finding it difficult because I dont know how to provide the commit message through script.


I am thankful to all the developers who have pointed out to me that this is not the way a version control system is supposed to be used. I agree. If I do a daily commit many of the versions will remain in broken state.

My case is different. I am not really interested in maintaining versions that wont break. I am more interested in keeping backup of my code. I work in a weird way on a remote machine through winSCP.
I want something that will save every minor change I make so that just in case I do 'rm -rf' in some directory I wont lose most of my work.


This does not seem like a very good idea, but, if you still want to do it, something like this would suffice:

COMMIT = cat ~/commit_message
git commit -m $COMMIT

And, you can change ~/commit_message to whatever you like everyday.