Skip to content

Instantly share code, notes, and snippets.

@thespacedoctor
Last active May 5, 2021 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thespacedoctor/2b9a9a08becf0eaa276f to your computer and use it in GitHub Desktop.
Save thespacedoctor/2b9a9a08becf0eaa276f to your computer and use it in GitHub Desktop.
[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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment