thespacedoctor
1/5/2016 - 9:21 PM

[Git Repo and Github Sync] Place at the root of a git repo and run from cron to schedule syncs with remote repo #sync #github #repo

[Git Repo and Github Sync] Place at the root of a git repo and run from cron to schedule syncs with remote repo #sync #github #repo

#!/bin/sh

if [ -x /usr/local/bin/keychain ]; then
  /usr/local/bin/keychain ~/.ssh/id_rsa  
  . ~/.keychain/`/bin/hostname`-sh
fi

DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HOST="$(hostname)"
cd $DIR
git add . --all
git commit -m 'cron-job on '$HOST
git pull
git push