Sync Command Options
Thesync command synchronizes environment variable keys across all .env* files in your project directory.
Command Usage
Options
Skip creating a backup before syncing. By default, env-twin creates a timestamped backup in the
.env-twin/ directory before making any changes.Warning: Using this option means you won’t have an automatic rollback point if something goes wrong.Example:Skip confirmation prompts and auto-accept non-destructive actions. This is useful for CI/CD pipelines or automated workflows.Aliases:
-yExample:Output the analysis report in JSON format instead of the interactive CLI interface. This is useful for programmatic consumption or AI-powered tools.Example:
Specify the “Source of Truth” file. Keys will be synced FROM this file to other .env* files. If not specified, env-twin will prompt you to choose or use a union of all files.Aliases:
--srcExample:How Sync Works
The sync command performs the following operations:- Detects all .env* files in the current directory (.env, .env.local, .env.development, .env.testing, .env.staging, .env.example)
- Analyzes differences between files
- Interactively asks how to resolve missing keys (Add Empty, Copy Value, Skip)
- Ensures .env.example contains all keys with placeholder values
- Preserves existing values and file structure
- Creates a backup in .env-twin/ before modifying files (unless
--no-backupis used)