Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Auto Commit Daily

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.

like image 490
Smith Dwayne Avatar asked Sep 04 '18 06:09

Smith Dwayne


People also ask

Should I push every commit?

If you commit, push. Ideally, you should commit every time you check off a task. You should never commit a half-written function without first writing comments and perhaps even some pseudo code. The same goes for a file.


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
like image 98
Victor Wong Avatar answered Sep 24 '22 16:09

Victor Wong