Is this a reproducible bug?
Current behavior
herdr worktree create --branch NAME always tries to create NAME as a new branch. If NAME already exists locally, Herdr runs the equivalent of git worktree add -b NAME <checkout> <base>, and Git fails with fatal: a branch named 'NAME' already exists.
This affects both the CLI/socket worktree.create path and the New worktree keybinding/dialog. Related: #657 covered the stuck/error-display path; this report is specifically about allowing existing local branches.
Expected behavior
If NAME already exists as a local branch and is not checked out by another worktree, Herdr should create the checkout with git worktree add <checkout> NAME. If NAME does not exist, keep the current new-branch behavior from --base or HEAD. If the branch is already checked out elsewhere, surface Git's error or guide the user to worktree open.
Reproduction
- In a repo with one commit, create a branch:
git branch existing-branch.
- Run
herdr worktree create --cwd /path/to/repo --branch existing-branch --json, or use the New worktree keybinding and enter existing-branch.
- Herdr attempts to create the already-existing branch instead of checking it out, so worktree creation fails.
Impact
This makes Herdr worktree creation awkward for the common flow where a branch already exists from previous work or after removing an old checkout. Users have to drop to raw git worktree add <path> <branch> or use a separate open-existing flow instead of the create command/dialog doing the expected thing.
Environment
- Herdr version: current upstream
master behavior; also consistent with the 0.7.0 worktree-create command shape
- Update channel (stable or preview): source build / not channel-specific
- Operating system: Linux/NixOS; behavior comes from Git command construction and should be platform-independent
- Terminal: not terminal-specific
- Shell, if relevant: not shell-specific
- Relevant config, if any: worktree creation with default or configured
[worktrees].directory
Filed by Hermes Agent by Nous Research at user request. No PR is being opened; we will maintain this in a downstream fork since PRs to upstream require approval from maintainers.
Is this a reproducible bug?
Current behavior
herdr worktree create --branch NAMEalways tries to createNAMEas a new branch. IfNAMEalready exists locally, Herdr runs the equivalent ofgit worktree add -b NAME <checkout> <base>, and Git fails withfatal: a branch named 'NAME' already exists.This affects both the CLI/socket
worktree.createpath and the New worktree keybinding/dialog. Related: #657 covered the stuck/error-display path; this report is specifically about allowing existing local branches.Expected behavior
If
NAMEalready exists as a local branch and is not checked out by another worktree, Herdr should create the checkout withgit worktree add <checkout> NAME. IfNAMEdoes not exist, keep the current new-branch behavior from--baseorHEAD. If the branch is already checked out elsewhere, surface Git's error or guide the user toworktree open.Reproduction
git branch existing-branch.herdr worktree create --cwd /path/to/repo --branch existing-branch --json, or use the New worktree keybinding and enterexisting-branch.Impact
This makes Herdr worktree creation awkward for the common flow where a branch already exists from previous work or after removing an old checkout. Users have to drop to raw
git worktree add <path> <branch>or use a separate open-existing flow instead of the create command/dialog doing the expected thing.Environment
masterbehavior; also consistent with the 0.7.0 worktree-create command shape[worktrees].directoryFiled by Hermes Agent by Nous Research at user request. No PR is being opened; we will maintain this in a downstream fork since PRs to upstream require approval from maintainers.