A lightweight helper that automatically commits and pushes one or more local directories to a Git remote over SSH.
- Per-repo config: path, remote, branch, push on/off, commit message
- Safe background operation: single-instance lock, optional daemon mode, pid/log files, graceful shutdown
- SSH-first connectivity checks: don’t try to push when the SSH endpoint is unreachable
- Correct push behavior: fetch/rebase to avoid non-fast-forward pushes; push even if there are no new file changes (e.g. previously-offline commits)
- Low overhead: do nothing when idle; short timeouts for git operations
- Clear logs: enough output to understand what happened on each run
- Python 3
git- SSH configured for your remote (e.g. GitHub SSH keys and
ssh-agent)
Track a directory (existing repo or a plain folder):
./sync.py add ~/notes --remote git@github.com:USER/notes.git --branch mainList tracked directories:
./sync.py listRun one sync pass:
./sync.py syncRun continuously in the foreground (default interval from config):
./sync.py runRun continuously in the background (daemon mode):
./sync.py run --daemon --pidfile ~/.config/git-sync/git-sync.pid --logfile ~/.config/git-sync/git-sync.logStop a daemon:
./sync.py stop --pidfile ~/.config/git-sync/git-sync.pidConfig is stored at:
~/.config/git-sync/config.json
Defaults include:
interval_minutes: 5network_host:github.comnetwork_port: 22
network_host / network_port are used as a fallback if a tracked entry has no remote URL; when a remote is set, git-sync infers the SSH host/port from the remote when possible.