Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Show HN: A tool to sync env files to your Git worktrees

A developer created git-env, a small git extension that automatically syncs .env files from a primary Git worktree into newly created linked worktrees, solving a common frustration with existing worktree management tools that lack this feature.

Background

- **Git worktrees** let you check out multiple branches of the same repository in separate directories at the same time, so you can work on different features without stashing or cloning the repo again. - **.env files** hold environment-specific configuration (API keys, database URLs) that is never committed to version control for security reasons. Tools like Docker and many frameworks (Rails, Laravel, Node.js) rely on them. - The problem: when you create a new worktree, the .env file from your main copy isn't automatically carried over. While several worktree managers (Conductor, Emdash, Sculptor, Superset) support a "setup script" hook, the author got tired of manually pasting a shell snippet into every new worktree. - **git-env** is a small Git extension by developer Alex Ward that syncs your .env file from the primary worktree into any linked worktree with one command (`git env sync`), handling conflicts and reporting what was copied.

Related stories