Env-mage Docs

Sync

Sync env files

sync

Synchronizes variables between environment files using different strategies.

Usage

env-mage sync [options]

Options

OptionDescriptionDefault
--source <path>Source file.env
--target <path>Target file.env.example
--strategy <n>Sync strategy: merge, overwrite, preservemerge
--backupCreate backup before changestrue
--no-backupSkip backup creationfalse

Example

env-mage sync --source .env --target .env.example --strategy merge

Example 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