Secure and Sensible git repo administration
Safely update a git repo from a remote source.
Emphasis on safety: make no change which is not guaranteed to be OK. This makes the script safe to run automatically, even while you occasionally work on both the local or the remote repo.
gitsync.sh [-v] REPO_DIR LOCAL_BRANCH REMOTE REMOTE_BRANCH
-v : verbose: Print command output.
Default behavior is to only print errors.
gitsync.sh /some/repo master origin master
Works with bare repos as well, no change in syntax: (if you’re not familiar: a bare repo is what a server stores, you can’t work inside it)
gitsync.sh /bare/repo master other_server master
cron
jobUsing crontab -e
:
PATH=/usr/sbin:/usr/bin
* * * * * gitsync.sh /home/joe/git-shell_bind master origin master
Fancier: log to syslog:
PATH=/usr/sbin:/usr/bin
* * * * * gitsync.sh /home/joe/git-shell_bind master origin master 2>&1 | logger -e -t gitsync