Syncwave is a command-line tool designed for syncing files and directories using efficient compression methods, like zstd. It integrates with Git by adding hooks to automatically sync files on push and pull operations. This tool simplifies managing large files or assets in Git repositories without committing them directly.
- Fast Compression: Uses zstd compression to create efficient backups of directories.
- Git Integration: Automatically syncs files before Git pushes and after checkouts using Git hooks.
- Customizable: Easily specify which files and directories to include in sync using patterns.
- Cross-Platform: Works on Linux, macOS, and Windows.
- Keep Latest: Option to keep only the most recent archive for each branch.
.gitignoreSyncing: Automatically updates.gitignoreto exclude files that are synced, preventing large assets from being accidentally committed.- Cloud Storage: Use Syncwave with cloud services like Google Drive, MEGA, or your own network drive for syncing archives. Note: Access management is handled by the respective cloud provider.
- Clone the repository:
git clone https://github.com/yourusername/syncwave.git
cd syncwave- Build the application:
You need to have Go installed. You can install Go from here.
go build -o syncwaveFor windows:
go build -o syncwave.exe- Move the binary to your system's
PATHfor easy access (optional but recommended):
mv syncwave /usr/local/bin/To set up Syncwave in your Git project, run the following command. This will
create a sync.yaml file and add Git hooks to manage syncing on push and
checkout.
syncwave initsync.yaml: This file contains your sync configuration, such as file patterns and directories to sync.
You can manually trigger a sync of your files by running the following command:
syncwave syncThis will create a compressed zstd archive of the specified files based on the patterns in sync.yaml. Files that match the patterns and any large files (if you've set a max file size) will automatically be added to both the .gitignore and the archive, ensuring they are not committed to your Git repository by accident.
When you switch branches or perform a Git checkout, Syncwave will automatically pull synced files from the cloud directory. You can manually pull files using:
syncwave pullBefore pushing changes to a Git repository, Syncwave will automatically push synced files. To manually trigger this process:
syncwave pushThe sync.yaml file defines what files and directories should be included in
the sync process. By default, it includes patterns for common assets like .jpg
and .png files. You can customize it to fit your project's needs. The
keep_latest option determines whether only the most recent archive for each
branch should be kept.
Additionally, files that match your patterns or exceed the specified size limit are automatically added to .gitignore, preventing large assets from being committed to your repository.
Example sync.yaml:
# sync.yaml - Syncwave configuration file
cloud_dir: "/path/to/cloud"
patterns:
- "*.jpg"
- "*.png"
- "assets/*"
keep_latest: true
max_file_size: 10485760 # Maximum file size in bytes (e.g., 10 MB)cloud_dir: Specifies where the compressed files will be stored.patterns: List of file patterns to include in the sync. Use*as a wildcard.keep_latest: If set totrue, only the most recent archive for each branch will be kept. Iffalse, older archives will not be removed automatically.max_file_size(NOT READY YET): Files larger than this size (in bytes) will automatically be added to .gitignore and included in the archive. This option is optional and can be left undefined.
You can specify a cloud_dir that points to cloud-synced folders like those from Google Drive, MEGA, or your own network-attached storage (NAS). Note that Syncwave itself doesn’t handle authentication or file transfer to cloud providers — you’ll need to manage that separately via the respective cloud service's app or sync mechanism.
For example, you can point cloud_dir to a Google Drive or MEGA-synced folder on your local system:
cloud_dir: "/path/to/Google Drive/syncwave"This will ensure that archives are stored in your cloud provider's folder, and they will be synced automatically by the cloud service’s app.
Syncwave automatically manages Git hooks:
- Pre-push hook: Runs
syncwave pushbefore pushing changes to the remote repository. - Post-checkout hook: Runs
syncwave pullafter a Git checkout. These hooks are set up when you runsyncwaveinit.
We welcome contributions! Here's how you can help:
- Fork the repository.
- Create a new feature branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature/your-feature). - Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.