Skip to content

Add --worktree flag to enable isolated parallel Qwen Code sessions using Git worktrees #2194

@jqueguiner

Description

@jqueguiner

What happened?

Description

Running multiple Qwen Code sessions in the same repository currently causes conflicts because all sessions operate on the same working directory and file state.

This issue proposes adding a --worktree flag that creates isolated Git worktrees for each session, allowing developers to run multiple Qwen Code instances in parallel without interfering with each other.

The implementation is inspired by Claude Code's worktree-based parallel session model.

Motivation

When developers run multiple AI-assisted coding sessions simultaneously, they often want each session to modify files independently.

Without isolation:

  • Sessions overwrite each other's changes
  • File state becomes inconsistent
  • Experiments across multiple features become difficult

Using Git worktrees allows:

  • Shared git history
  • Fully isolated file states
  • Parallel development workflows

Proposed Solution

Introduce a CLI flag:

--worktree [name]

When enabled, Qwen Code will automatically create and use a Git worktree for the session.

Behavior

  1. Validate the current directory is a Git repository
  2. Create a worktree under:
.qwen/worktrees/<name>
  1. Create a branch:
worktree/<name>
  1. Change the process working directory to the new worktree
  2. Start the Qwen Code session inside the isolated environment

Worktree naming

Two modes are supported:

Auto-generated name

qwen --worktree

Example generated worktree:

.qwen/worktrees/session-17482

Custom name

qwen --worktree feature-auth

Worktree path:

.qwen/worktrees/feature-auth

Branch:

worktree/feature-auth

Usage Examples

Single isolated session

qwen --worktree feature-auth

Auto-generated session

qwen --worktree

Multiple parallel sessions

qwen --worktree feature-a &
qwen --worktree feature-b &

Each session runs in its own independent working directory.

Features

  • Auto-generated or custom worktree names
  • Isolated working directories
  • Dedicated branch per worktree
  • Git repository validation
  • Clear error handling and user feedback

Expected Outcome

Developers will be able to run multiple Qwen Code sessions concurrently, each operating on a fully isolated workspace while sharing the same Git repository history.

What did you expect to happen?

NA

Client information

NA

Login information

NA

Anything else we need to know?

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/needs-triageIssue needs to be triaged and labeledtype/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions