As I'm now using git for version control of my latex documents that I am writing I have automated the committing to git.
This is the script that I'm using, called
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/bin/bash # from http://superuser.com/questions/629898/how-to-auto-commit-to-my-git-repository-using-cron # 29-09-14 logfile="/home/$USER/logs/gitcron.txt" exec > >(tee -a $logfile) 2>&1; cd /home/$USER/research/obnam/ /usr/bin/git add -A /usr/bin/git commit -am "update `date`" # /usr/bin/git push cd /home/$USER/research/beeb/ /usr/bin/git add -A /usr/bin/git commit -am "update `date`" # /usr/bin/git push
This is saved to
/home/$USER/bin and run from this cron-line -
00 */3 * * * DISPLAY=:0 /home/$USER/bin/gitcron
And this is the
.gitignore that stops some files from being committed.
# created 27-09-14 ob2014.acn ob2014.acr ob2014.alg ob2014.aux ob2014.bcf ob2014.blg ob2014.glg ob2014.glo ob2014.gls ob2014.idx ob2014.ilg ob2014.ind ob2014.ist ob2014.out ob2014.run.xml ob2014.toc *.aux
What this does is that every three hours it checks all the files of
obnam and if it finds any changes that
should be committed, and are not in
.gitignore then they will be committed and an email sent to me showing what it has
done. And this email looks like this -
From: root@london (Cron Daemon) Subject: Cron <$USER@london> DISPLAY=:0 /home/$USER/bin/gitcron To: $USER@localhost Date: Fri, 03 Oct 2014 12:00:08 +0100 (1 day, 2 hours, 36 minutes ago) [devel 64f2dfc] update Fri 3 Oct 12:00:03 BST 2014 6 files changed, 181 insertions(+), 160 deletions(-) On branch devel nothing to commit, working directory clean
This shows that there were 6 changed files and committed in
/home/$USER/research/obnam, and there is nothing to
/home/$USER/research/beeb. This simplifies things if I forget to manually commit stuff by doing it all for
me, and it could be run once a day if you wanted, just change its frequency in your crontab.