git-sync-rs
A Rust implementation of automatic git repository synchronization with file watching capabilities. This tool automatically commits, pushes, and pulls changes to keep your repositories in sync.
Features
- ๐ Automatic synchronization - Commits, fetches, pushes, and merges/rebases automatically
- ๐ File watching - Monitors file changes and triggers sync with debouncing
- ๐ซ Gitignore support - Respects
.gitignorepatterns - ๐ฆ Repository cloning - Automatically clones repositories if they don't exist
- ๐ SSH authentication - Works with SSH keys (with fallback to git command)
- โก Efficient - Only syncs when changes are detected
- ๐งช Dry-run mode - Test your configuration without making changes
- ๐ง Flexible configuration - Configure via TOML, environment variables, or CLI
Installation
Usage
Basic Commands
# Check if repository is ready to sync
# Perform one-time sync
# Watch for changes and auto-sync
# Watch with custom intervals
Environment Variables
Fully compatible with the original git-sync environment variables:
GIT_SYNC_DIRECTORY- Repository pathGIT_SYNC_REPOSITORY- Repository URL for initial cloneGIT_SYNC_INTERVAL- Sync interval in secondsGIT_SYNC_NEW_FILES- Whether to add new files (true/false)GIT_SYNC_REMOTE- Remote name (default: origin)GIT_SYNC_COMMIT_MESSAGE- Custom commit message template
Watch Mode
Watch mode monitors your repository for changes and automatically syncs them:
# Basic watch mode
# With custom debounce (wait 2 seconds after changes)
# With periodic sync every 5 minutes
# Dry run mode (detect changes but don't sync)
Configuration File
Create a configuration file at ~/.config/git-sync-rs/config.toml:
[]
= 300
= true
= "Auto-sync: {hostname} at {timestamp}"
= "origin"
[[]]
= "~/my-notes"
= true
[[]]
= "~/my-docs"
= "backup"
Command Line Options
-n, --new-files- Sync new/untracked files-r, --remote <name>- Specify remote name-d, --directory <path>- Repository path-v, --verbose- Enable verbose output-q, --quiet- Suppress non-error output--config <path>- Use alternate config file
Compatibility
This tool is designed to be a drop-in replacement for git-sync-on-inotify with additional features and better performance.
License
Licensed under either of:
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.