git-worktree-env (wte)
Per-worktree ports, local secrets, and development environment setup for Git.
wte makes linked worktrees runnable without giving every checkout the same
hard-coded ports or copying secrets into Git. A project profile identifies one
dedicated main worktree; every linked worktree created from it receives a
sticky port block and its declared local configuration.
Features
- Allocates contiguous, machine-wide port blocks with file locking.
- Keeps allocations stable for the lifetime of a worktree path.
- Recognizes linked and agent-created worktrees through their main worktree.
- Symlinks secrets from files outside the repository.
- Generates complete per-worktree configuration files from port templates.
- Starts optional dependency setup tasks after checkout without blocking Git.
- Preserves repository hooks behind a global hook dispatcher.
Requirements
- macOS or Linux
- Python 3.9+
- Git
Windows is not currently supported because wte uses POSIX file locks, symlinks, and Bash hooks.
Installation
With uv (recommended):
uv tool install git-worktree-env
From a source checkout:
uv tool install --editable .
pipx install git-worktree-env is also supported.
Quick start
wte init
cp examples/fullstack.yaml ~/.config/wte/my-project.yaml
$EDITOR ~/.config/wte/my-project.yaml
wte validate
wte hooks install
Each project must have a dedicated main worktree:
name: example-fullstack
match:
main_worktree: $HOME/code/example-app
ports:
- id: frontend
- id: backend
secrets:
- source: $HOME/.config/example-app/backend.env
target: apps/backend/.env
writes:
- path: apps/frontend/.env.development
body: |
VITE_PORT=${frontend}
VITE_API_URL=http://127.0.0.1:${backend}
init:
- command: npm install
cwd: .
skip_if: node_modules
See examples/fullstack.yaml for a complete profile.
Commands
wte init Create ~/.config/wte
wte apply [PATH] Apply a profile without running initializers
wte list List live worktree allocations
wte gc Remove stale or invalid allocations
wte release PATH Release one allocation explicitly
wte validate Validate config and profiles
wte doctor Diagnose config, registry, secrets, and hooks
wte hooks install Install the global Git hook dispatcher
wte hooks status Show dispatcher state
wte hooks uninstall Restore the previous core.hooksPath
The dispatcher invokes wte only for post-checkout. Other installed hook names
exist solely to forward an earlier global hook or a repository-local hook.
wte hooks install refuses to replace an existing global core.hooksPath
unless --force is supplied; forced installation records and chains it.
Configuration and state
By default all machine-local files are kept together:
~/.config/wte/
├── config.yaml
├── my-project.yaml
├── another-project.yaml
├── hooks/
└── state/
├── ports.json
├── ports.lock
└── hooks-state.json
Set WTE_CONFIG_HOME to override this location. XDG_CONFIG_HOME is respected
when no explicit override is present.
Every root-level YAML file except config.yaml is loaded as a project profile.
The state/ directory is managed by wte and should not be edited or synchronized.
The machine-wide allocation range is configured in config.yaml:
port_range:
start: 35000
end: 39999
The default range is 35000-39999. Deleted worktree paths are reclaimed
during the next allocation; wte gc also verifies remaining paths with Git.
Registry writes are atomic, and a corrupt registry is reported rather than
silently replaced.
Security model
Profiles are trusted local configuration. Secret contents are never stored in the registry and secret sources remain outside the repository. Write and secret targets are restricted to the matched worktree. Initializer commands are passed to Bash and therefore must not come from untrusted profiles.
Development
uv sync
uv run pytest
License
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 git_worktree_env-0.1.0.tar.gz.
File metadata
- Download URL: git_worktree_env-0.1.0.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca822123989fbad5cdd7886d6c9fa5270bfd306a67487dd412026f0efb794259
|
|
| MD5 |
563af6ec48973b4b1bde83585e44a977
|
|
| BLAKE2b-256 |
d7ec79eb43a6bd0b4df407fb59fcd6b5eb210570921adef73ea2ec044c697810
|
File details
Details for the file git_worktree_env-0.1.0-py3-none-any.whl.
File metadata
- Download URL: git_worktree_env-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9b9a480d5442a52de2ed2d9fa7fb9c7c11344c35b38400f1fad29f3fc2c24c4
|
|
| MD5 |
d05ada04a32155a202be8cba9b243744
|
|
| BLAKE2b-256 |
992cf8eaf2b3ffd25eea3c983264a9f80e109db988bfc77bd8bb3b228140f6f9
|