I\'d like to use git to record all the changes to a file.
Is there a way I can turn git \'commit\' on to automatically happen every time a file is updated - so ther
This script doesn't run when a user changes the file, but it could be run as a cron job (by dropping it into an /etc/cron.* directory), which is also a reasonable solution.
This script will iterate through your /srv/www directory (change it to wherever all of your sites are stored), add, commit, and push all files, and log everything to /var/log/gitlog.txt
now=$(date +"%m.%d.%Y_%T")
logfile='/var/log/gitlog.txt'
for dir in /srv/www/*/
do
echo -e '\n' >> $logfile
echo "autocommit $dir $now" >> $logfile
echo "--------------------------" >> $logfile
cd $dir
git add . >> $logfile
git commit -am "autocommit $now" >> $logfile
git push origin master >> $logfile
done