envstash-0.1.3 is not a library.
envstash
A CLI tool for managing .env files across git branches. Save, version, diff, restore, and share environment variables with optional encryption.
Install
From crates.io:
Pre-built binaries:
Download the latest release from GitHub Releases and extract the binary to a directory in your PATH:
# macOS (Apple Silicon)
|
# macOS (Intel)
|
# Linux (x86_64)
|
Debian/Ubuntu:
Download the .deb from GitHub Releases and install:
Fedora/RHEL:
Download the .rpm from GitHub Releases and install:
Quick start
# Initialize the store
# Save the current .env file
# Save with a note
# List saved versions
# Restore a saved version
# See what changed between versions
Features
- Version .env files per git branch and commit
- Diff variables by name (order-independent)
- Restore saved versions to disk, or inject into the shell environment
- Share exports with teammates (with optional GPG or password encryption)
- Dump/load the entire store for backup and migration
- Works outside git repos using folder path as identifier
Commands
| Command | Description |
|---|---|
envstash init |
Initialize the store (choose encryption mode) |
envstash save [file] [-m msg] |
Save a .env file with optional message |
envstash list |
List saved versions on the current branch |
envstash diff <a> <b> |
Diff two versions (by number or hash) |
envstash apply <version> |
Restore a version to disk |
envstash env [version] |
Print export statements for shell eval |
envstash exec [version] -- <cmd> |
Run a command with saved env vars |
envstash history |
Show what changed between consecutive versions |
envstash delete <version> |
Remove saved versions |
envstash global |
List all projects with saved .env files |
envstash share |
Export a version for sharing |
envstash import <file> |
Import a shared export |
envstash dump <path> |
Export the entire store |
envstash load <path> |
Import a full dump |
Encryption
Three modes, chosen at init time:
Architecture (inspired by Tomb):
- A random AES-256-GCM key encrypts variable values at rest
- The AES key is wrapped with GPG or a password-derived key
- Metadata (branches, timestamps, file paths) stays plaintext for fast queries
- GPG mode: one Yubikey touch per gpg-agent cache window, not per operation
The key file location can be overridden with --key-file or ENVSTASH_KEY_FILE.
Shell integration
# Load variables into current shell
# Run a one-off command with saved variables
# Isolated mode (only saved variables, no inherited env)
Supports bash, fish, and json output via --shell.
Sharing
# Export latest version to stdout
# Encrypted export
# Import
|
# Full store backup
Storage
Data lives in ~/.local/share/envstash/:
~/.local/share/envstash/
├── store.db # SQLite (mode 0600)
└── key.gpg # AES key wrapped in GPG/password (mode 0600)
Building
License
GPL-3.0