Sync
Sync env files
sync
Synchronizes variables between environment files using different strategies.
Usage
env-mage sync [options]Options
| Option | Description | Default |
|---|---|---|
--source <path> | Source file | .env |
--target <path> | Target file | .env.example |
--strategy <n> | Sync strategy: merge, overwrite, preserve | merge |
--backup | Create backup before changes | true |
--no-backup | Skip backup creation | false |
Example
env-mage sync --source .env --target .env.example --strategy mergeExample Output
✓ Reading source file: .env
✓ Reading target file: .env.example
✓ Creating backup: .env.example.backup
✓ Merging environment variables
➕ Added: NEW_API_KEY
➕ Added: DEBUG_MODE
✓ Writing changes to target file
✓ Sync completed successfully!Things to Know
- merge (default): Adds missing keys from source to target
- overwrite: Completely replaces target with source content
- preserve: Only adds keys that don't exist in target
- Backups are automatically created unless disabled with
--no-backup - Comments and formatting are preserved