fix: add --force flag to worktree creation for existing branches#5931
fix: add --force flag to worktree creation for existing branches#5931Githubguy132010 wants to merge 3 commits intoKilo-Org:mainfrom
Conversation
When creating a worktree for an existing branch (like main), Git refuses if that branch is already checked out in another worktree. This fix adds the --force flag to allow multiple agents to run on main with their own worktrees. Fixes: 'main' is already checked out error when creating worktrees
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
🦋 Changeset detectedLatest commit: 24f97b3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
A better approach that we can adapt: We allow running multiple agents in the same worktree. Thanks for the input! |
|
@marius-kilocode wouldn't the agents conflict with eachother? |
|
Using |
Context
When creating a worktree for an existing branch (like
main), Git refuses if that branch is already checked out in another worktree. This prevents users from running multiple agents on the same branch (e.g.,main) with their own worktrees.The error was:
Implementation
Added the
--forceflag to thegit worktree addcommand when using an existing branch inWorktreeManager.createWorktree(). This allows the same branch to be checked out in multiple worktrees simultaneously.Changes:
src/core/kilocode/agent-manager/WorktreeManager.ts- Added--forceflag to worktree creation commandsrc/core/kilocode/agent-manager/__tests__/WorktreeManager.test.ts- Updated test to expect--forceflagScreenshots
N/A
How to Test
mainbranchmainas the branch (or leave unselected to use current branch)Get in Touch
thomas07374