Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Latest commit

 

History

History
53 lines (36 loc) · 1.02 KB

gitsync.md

File metadata and controls

53 lines (36 loc) · 1.02 KB
title
gitsync

gitsync.sh

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.

Synopsis

gitsync.sh [-v] REPO_DIR LOCAL_BRANCH REMOTE REMOTE_BRANCH
	-v	:	verbose: Print command output.
			Default behavior is to only print errors.

Examples

Running locally

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

As a cron job

Using 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