git-wtree
v0.1.5
Published
Git worktree manager with .env syncing and IDE integration
Readme
git-wtree
Git worktree manager with .env syncing and IDE integration
Streamline your git worktree workflow: create isolated branches, sync environment files, install dependencies, and open your IDE — all in one command.
Install
npm install -g git-wtreeUsage
gitwtree <command>
# or
gwt <command>Commands
| Command | Description |
| ---------------------------------- | -------------------------------------------------------------- |
| gwt add <branch> [--from <base>] | Create a worktree, sync .env files, and install dependencies |
| gwt rm <branch> | Remove a worktree |
| gwt ls | List all worktrees |
| gwt open <branch> | Open a worktree in your IDE |
| gwt config | Show current configuration |
| gwt config ide | Configure your IDE |
| gwt config scan-dirs [dirs] | Set directories to scan for .env files |
| gwt help | Show help |
gwt add <branch>
Creates a git worktree for the given branch, copies .env files from the main repo, and runs the package manager install.
- If the branch doesn't exist, it's created from
HEADby default — use--fromto specify a different base. - If the branch already exists locally, it fetches the latest remote changes and resets to them (handles force-pushes cleanly).
gwt add my-feature # create from HEAD
gwt add my-feature --from production # create from production
gwt add codex/fix-bug # checkout existing branch, reset to remotegwt open <branch>
Opens the worktree in your configured IDE. On first use, a wizard will prompt you to choose your IDE.
gwt open my-featureTo reconfigure your IDE at any time:
gwt config ide.env syncing
By default, gwt add recursively scans the repo for .env* files (excluding node_modules, .git, dist, etc.) and copies them into the new worktree.
To restrict scanning to specific directories:
gwt config scan-dirs apps/api,apps/webTo reset back to auto scan:
gwt config scan-dirs --resetWorktree location
Worktrees are created as siblings of your repo directory:
~/projects/
myrepo/ ← main repo
myrepo-my-feature ← worktree created by gwtSupported IDEs
VS Code, Cursor, Zed, WebStorm, IntelliJ IDEA, PyCharm, GoLand, Vim, Neovim, Sublime Text — or any custom IDE via the "Other" option in the wizard.
Requirements
- Node.js >= 18
- Git >= 2.5
License
MIT
