A simple git worktree management tool that creates worktrees in the .git/worktree directory of your current Git repository.
npm install -g workhereOr run directly with npx:
npx workhere@latestworkhere create [branch-name]
workhere add [branch-name] # Alias for createIf no branch name is specified, it will automatically create one with a random name like alice-smith-a1b2 or bob-jones-c3d4.
workhere list
workhere ls # Short alias for listShows all worktrees managed by workhere in the current repository.
workhere delete <branch-name>
workhere remove <branch-name> # Alias for delete
workhere rm <branch-name> # Short alias for deleteRemoves the specified worktree and its associated branch.
workhere resetRemoves all worktrees in the .git/worktree directory.
To automatically add the current folder name as a prefix to the worktree folder name (branch name stays unchanged):
workhere create -p [branch-name]
workhere add --prefix [branch-name]Examples (if current folder is "workhere"):
workhere add -p feature→ folder:workhere-feature, branch:featureworkhere add -p→ folder:workhere-alice-smith-a1b2, branch:alice-smith-a1b2(auto-generated)workhere add feature→ folder:feature, branch:feature(no prefix)
To execute a script after creating the worktree:
workhere create -s "npm install && npm run dev" feature-branch
workhere add --script "pnpm install" feature-branchThis will:
- Create a worktree named
feature-branch - Change to the created worktree directory
- Execute the specified script (in this example:
npm install && npm run dev)
By default, a new worktree is derived from the current HEAD. To derive it from a specific branch or commit instead:
workhere add --base main feature-branch
workhere add -b origin/develop feature-branchThis creates feature-branch based on the specified ref (main in the first example) regardless of the currently checked-out branch.
To force delete worktrees even if they have uncommitted changes:
workhere delete -f <branch-name>
workhere reset -f- Creates worktrees in the
.git/worktreedirectory of the current repository - Supports post-creation script execution (
-soption) - Checks for existing worktree conflicts
- Verifies if the current directory is a Git repository
- Enforces execution from the repository root
workhere create feature/new-feature
workhere add feature/new-feature # Using aliasworkhere add -p feature
# Creates folder: yourproject-feature, branch: feature (if current folder is "yourproject")workhere add --base main feature/new-feature
# Creates feature/new-feature based on main, not the current branchworkhere create -s "pnpm install" bugfix/issue-123workhere add -p -s "npm install && npm run dev" develop
# Creates folder: yourproject-develop, branch: develop, and runs the scriptworkhere listworkhere delete feature/old-featureworkhere resetworkhere reset --force- Node.js >= 14.0.0
- Git
MIT
Please report bugs and feature requests to GitHub Issues.