@yukiakai/gitenv
v1.0.0
Published
A flexible find-up implementation supporting string, RegExp, CJS/ESM dual build, and custom matcher.
Maintainers
Readme
@yukiakai/gitenv
Sync and manage environment files across machines safely using a private Git repository, with profile-based configuration.
Why?
Developers often:
- accidentally commit
.envfiles - lose environment variables
- duplicate configs across machines
gitenv solves this by:
- storing your env files in a separate private repo
- syncing them via simple commands
- keeping your main repo clean and safe
Features
- Sync
.envfiles between local and remote repo - Profile-based configuration (like
prod,local,ci) - Config inheritance via
extends - Glob support (
**/*.env) - Smart ignore
- Diff preview (optional)
- Prune mode (remove stale files)
- Fast & deterministic sync
Installation
npm install -g @yukiakai/gitenvQuick Start
1. Create a private repo
Create a Git repository (GitHub, GitLab, etc.):
my-env-store (private)2. Initialize
gitenv init <repo-url> --project-name <name>Example:
gitenv init [email protected]:you/env-store.git --project-name gitenvThis will:
- create
gitenv.config.json - create
.gitenv/folder - add
.gitenvto.gitignore
Project name is used as a unique identifier for syncing your environment variables. Changing this name later will make existing env data inaccessible.
3. Configure tracked files
Edit:
gitenv.config.json{
"default": {
"repo": "[email protected]:you/env-store.git",
"tracked": [
".env",
"apps/api/.env"
]
}
}
4. Push your env
gitenv push -m "update env"5. Pull on another machine
gitenv pullProfiles
Profiles define how env files are synced.
Select a profile using:
GITENV_PROFILE="name"Example config
{
"default": {
"repo": "[email protected]:your/env-repo",
"projectName": "my-app",
"tracked": ["**/*.env"],
"ignore": [],
"strict": false,
"diff": true,
"version": 1
},
"prod": {
"extends": ["default"],
"tracked": [".env.prod"]
},
"local": {
"extends": ["default"],
"ignore": [".env.local"]
}
}gitenv example
Generate .env.example from .env
gitenv example .env
gitenv example -p profileBackup
Before overwriting files on pull, gitenv creates a backup:
.gitenv/backups/You can restore manually.
Safety
.gitenvis automatically added to.gitignore- prevents leaking env data into your main repo
Do not remove it.
Recommended workflow:
gitenv push # before switching machine
gitenv pull # on another machineLicense
MIT
