Git Auto Commit Daily

Viewed 5164

Could I do take commit my changes in a directory by a daily routine? Say, In every 12 AM at early morning, It should commit all the changes in that directory automatically? Is it possible in git? I get some answers for auto commit for every changes. But I want it for daily once commit.

1 Answers

If you simply want to commit ALL changes every morning at 12 AM, you can do this using a cronjob.

Assuming that you are using a linux distribution with bash, you can write a bash script that does the commit

#!/bin/bash
cd <git directory> && git add -A && git commit * --allow-empty-message -m ''

Then you can place this cron job in /etc/cron.d/

0 0 * * * <username> /bin/bash <script location>

If you intend to run this as your own user only then you can instead add it to your personal crontab interactively by running

crontab -e
Related