A library to manage encrypted .env files with Git as a single source of truth
Project description
🧰 gitenvy
Securely store, version, and share your .env files using Git repositories — with built-in encryption and version tracking.
✨ Features
- 🔐 AES (Fernet) encryption for
.envfiles - 🕓 Versioning — every push creates a new version
- 🧩 Multi-repo support — manage multiple environments or teams easily
- 🌿 Branch-aware cloning and pushing
- ⚙️ Simple YAML-based config
- 🪄 Fully CLI-driven workflow
📦 Installation
pip install gitenvy
⚙️ Configuration
Configuration is stored in:
~/.gitenvy/config.yml
Example:
configs:
dotenvy-store:
branch: feature-test-checkout
key_path: ~/.gitenvy/keys/dotenvy-store.key
repo_path: C:\Users\swapn/.gitenvy/repos\dotenvy-store
repo_url: https://github.com/swapnilravi10/dotenvy-store
default: dotenvy-store
Each config entry represents one git-backed store for .env files.
You can manage multiple repositories and set one as default.
You do not manually create the config, instead use the init command.
🧩 Usage
🏁 Initialize gitenvy
Initialize and configure your environment store.
gitenvy init <repo_url>
Examples
# Clone and initialize repo
gitenvy init git@github.com:your-org/env-storage.git
# Clone to a custom local path
gitenvy init git@github.com:your-org/env-storage.git --path ~/.gitenvy/repos/custom-repo
# Clone and checkout a specific branch
gitenvy init git@github.com:your-org/env-storage.git --branch feature/config-refactor
🗂️ This automatically saves the repo info in your config file.
🚀 Push a .env file
Push a local .env file to your encrypted environment store.
gitenvy push --project <PROJECT> --env <ENV>
Examples
# Push using the default repo config
gitenvy push --project myapp --env dev
# Push using a specific repo config
gitenvy push --project myapp --env prod --repo-name dotenvy-store
Each push creates a new version under:
<repo>/<project>/<env>/<version>/
📥 Pull and decrypt a .env file
Retrieve and decrypt an environment file from the repo.
gitenvy pull --project <PROJECT> --env <ENV> [--version <VERSION>] [--out-path <PATH>] [--repo-name <REPO_NAME>]
Examples
# Pull latest .env for a project
gitenvy pull --project myapp --env dev
# Pull a specific version
gitenvy pull --project myapp --env dev --version 3
# Pull and save to a custom path
gitenvy pull --project myapp --env dev --out-path ./envs/.env.dev
# Pull from a specific repo config
gitenvy pull --project myapp --env staging --repo-name dotenvy-store
📋 List projects, environments, or versions
List what’s stored in your encrypted repo.
gitenvy list
gitenvy list --project <PROJECT>
gitenvy list --project <PROJECT> --env <ENV>
gitenvy list— Lists all projects.gitenvy list --project <PROJECT>— Lists all environments for a project.gitenvy list --project <PROJECT> --env <ENV>— Lists all versions for an environment.
⚙️ Manage config defaults and keys
Set the default repo
gitenvy set-default <REPO_NAME>
Sets which repo is used when no --repo-name is specified.
Get the Fernet key for a repo
gitenvy get-key <REPO_NAME>
Set the Fernet key for a repo
gitenvy set-key <REPO_NAME> <KEY>
👥 Working with a Team
When multiple teammates need to manage .env files securely in the same repo, gitenvy makes collaboration simple.
🧑💻 Team Member 1 — Initializes and Pushes
-
Initialize the repo
gitenvy init git@github.com:your-org/your-storage-repo.git
-
Push a
.envfilegitenvy push --project <PROJECT> --env <ENV>
-
Get the encryption key
gitenvy get-key <REPO_NAME>
Share this key securely with your teammates (e.g., using a secret manager or encrypted channel).
⚠️ Never commit or share the key publicly.
👩💻 Team Member 2 — Sets Up and Uses the Same Key
-
Initialize the same repo
gitenvy init git@github.com:your-org/your-storage-repo.git
-
Set the Fernet key received from teammate
gitenvy set-key <REPO_NAME> <KEY>
-
Start using it
gitenvy pull --project <PROJECT> --env <ENV> gitenvy push --project <PROJECT> --env <ENV>
Now both teammates can encrypt, push, and pull environment files securely using the same shared key.
🔄 Example Multi-Repo Workflow
You can maintain multiple repo configs and easily switch between them:
# Initialize two repos
gitenvy init git@github.com:org1/env-store.git
gitenvy init git@github.com:org2/env-store.git --branch secure-configs
# Push to a specific repo
gitenvy push --project webapp --env staging --repo-name org2-env-store
# Set default repo
gitenvy set-default org1-env-store
🧠 Notes
- Supports both HTTPS and SSH Git URLs seamlessly.
.envfiles are encrypted before every commit.- Each repo stores its own encryption key at
~/.gitenvy/keys/<repo>.key.
🛠️ Tech Stack
- Python 3.10+
- Click for CLI
- GitPython for Git operations
- cryptography for encryption
📜 License
This project is licensed under the MIT License.
🙌 Contributing
Contributions, issues, and feature requests are welcome!
Feel free to check out the issues page to get started.
Before contributing, please read our Code of Conduct.
Thank you for helping improve Gitenvy! 💜
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitenvy-1.2.3.tar.gz.
File metadata
- Download URL: gitenvy-1.2.3.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.7 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0473708183a70edea54138f7709d68ec7a1c63ec15ca2e67df0ac54fdfb7ab4
|
|
| MD5 |
64faf992daa607ed114f2faa878aee08
|
|
| BLAKE2b-256 |
603a5f0ead34ab8840720449f5eb5d452d7e0f9795cfc684818711c45a297d8a
|
File details
Details for the file gitenvy-1.2.3-py3-none-any.whl.
File metadata
- Download URL: gitenvy-1.2.3-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.7 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ac718ed03895522a2f69c95ec0d953653e9fded7b8c10f915ac96675842621b
|
|
| MD5 |
97c32d1140b128afabb5792c3453404e
|
|
| BLAKE2b-256 |
ff7f11d61013a7ba38f149d69f872df9019cf983faf1c7cd4a39d5c1d4029e45
|