-
Notifications
You must be signed in to change notification settings - Fork 181
docs: add worktrees feature documentation #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| --- | ||
| description: Use Git worktrees to work on multiple branches simultaneously with Roo Code, each in its own VS Code window. | ||
| keywords: | ||
| - worktrees | ||
| - git worktrees | ||
| - multiple branches | ||
| - parallel development | ||
| - branch management | ||
| - agentic coding | ||
| --- | ||
|
|
||
| # Worktrees | ||
|
|
||
| Git worktrees allow you to work on multiple branches of the same repository simultaneously by keeping them in different directories. Each worktree gets its own VS Code window with Roo Code, enabling parallel development without branch switching. | ||
|
|
||
| This is particularly powerful for agentic coding workflows where you might want to: | ||
|
|
||
| - Test different implementation approaches in parallel | ||
| - Review pull requests without disrupting your current work | ||
| - Run multiple tasks on different branches simultaneously | ||
| - Maintain separate environments for development and debugging | ||
|
|
||
| :::note Requirements | ||
| - Git must be installed on your system | ||
| - Your workspace must be a Git repository | ||
| - Multi-root workspaces are not supported | ||
| - Workspace must be at the repository root (not a subfolder) | ||
| ::: | ||
|
|
||
| --- | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Accessing Worktrees | ||
|
|
||
| You can access the worktrees feature in two ways: | ||
|
|
||
| 1. **Home Screen**: When you have multiple worktrees, a worktree selector appears at the top of the chat interface | ||
| - Click the selector to see all your worktrees | ||
| - Click on any worktree to switch to it | ||
| - Click the `+` button to create a new worktree | ||
| - Click the ⚙️ to manage worktrees | ||
|
|
||
| 2. **Settings Panel**: from the last point above or via Settings (⚙️) → Worktrees | ||
| - View and manage all your worktrees | ||
| - Create new worktrees | ||
| - Delete existing worktrees | ||
| - Configure `.worktreeinclude` settings | ||
| - Choose wheter to show the selector in the home screen | ||
|
|
||
| ### Creating Your First Worktree | ||
|
|
||
| 1. Open the Roo Code settings by clicking the gear icon | ||
| 2. Navigate to the "Worktrees" section | ||
| 3. Click the "Create worktree" button | ||
| 4. Fill in the required fields: | ||
| - **Base Branch**: The branch to create your new branch from (typically `main` or `develop`) | ||
| - **Branch Name**: Name for the new branch (e.g., `worktree/feature-name`) | ||
| - **Worktree Path**: Location where the worktree will be created | ||
| 5. Click "Create" | ||
| 6. Choose whether to open the new worktree in a new window or stay in your current window | ||
|
|
||
| The worktree will be created with all the files from the base branch, and you can immediately start working on it. | ||
|
|
||
| --- | ||
|
|
||
| ## Key Functionality | ||
|
|
||
| ### Switching Between Worktrees | ||
|
|
||
| Once you have multiple worktrees, switching between them is seamless: | ||
|
|
||
| **From the Home Screen**: | ||
| - Click the worktree selector at the top of the chat | ||
| - Select the worktree you want to switch to | ||
| - Choose whether to switch in the current window or open a new window | ||
|
|
||
| **From Settings**: | ||
| - Navigate to Settings → Worktrees | ||
| - Click on any worktree to switch to it in the current window | ||
| - Click the icon to open in a new window | ||
|
|
||
| :::tip Multiple Windows | ||
| Opening worktrees in new windows allows you to have multiple tasks running in parallel, each in its own workspace. This is ideal for comparing different approaches or working on multiple features simultaneously. | ||
| ::: | ||
|
|
||
| ### Managing Worktrees | ||
|
|
||
| **Viewing Your Worktrees**: | ||
| The worktrees list shows: | ||
| - Branch name (or "Detached HEAD" if not on a branch) | ||
| - Worktree path on your filesystem | ||
| - Status indicators (Primary, Locked) | ||
| - Current worktree is highlighted | ||
|
|
||
| **Deleting Worktrees**: | ||
| 1. Navigate to Settings → Worktrees | ||
| 2. Click the trash icon <Codicon name="trash" /> next to the worktree you want to delete | ||
|
|
||
|
|
||
| ### Copying Files with .worktreeinclude | ||
|
|
||
| By default, Git worktrees only include files tracked by Git. Untracked files like `node_modules`, `.env`, or build artifacts aren't copied. The `.worktreeinclude` feature solves this problem. | ||
|
|
||
| **How it Works**: | ||
| - Create a `.worktreeinclude` file at the root of your repository | ||
| - Add patterns for files/directories you want to copy (uses `.gitignore` syntax) | ||
| - Files must also be in `.gitignore` to be copied (intersection of both files) | ||
| - When creating a new worktree, matching files are automatically copied | ||
|
|
||
| **Setting Up .worktreeinclude**: | ||
|
|
||
| 1. Navigate to Settings → Worktrees | ||
| 2. If you don't have a `.worktreeinclude` file, you'll see a message at the bottom | ||
| 3. Click "Create from .gitignore" to automatically create one based on your `.gitignore` | ||
| 4. Edit the file to include only the patterns you want to copy (e.g., `node_modules`, `.env.local`) | ||
|
|
||
| **Example .worktreeinclude**: | ||
| ``` | ||
| node_modules | ||
| .env.local | ||
| .cache | ||
| dist | ||
| ``` | ||
|
|
||
| :::tip What Gets Copied | ||
| Only files that match BOTH `.worktreeinclude` AND `.gitignore` patterns are copied. This ensures you're only copying untracked files that you intentionally want to duplicate across worktrees. | ||
| ::: | ||
|
|
||
| ### Home Screen Integration | ||
|
|
||
| The worktree selector can be shown or hidden from the home screen: | ||
|
|
||
| 1. Navigate to Settings → Worktrees | ||
| 2. Toggle "Show worktrees in home screen" | ||
| 3. When enabled, the selector appears at the top of the chat when you have multiple worktrees | ||
| 4. When disabled, you can still manage worktrees from Settings | ||
|
|
||
| --- | ||
|
|
||
| ## Tips | ||
|
|
||
| - **Organized locations**: Use a consistent location like `~/.roo/worktrees/` for all your worktrees | ||
| - **Descriptive branch names**: Use clear naming like `worktree/feature-name` to identify worktree branches later on | ||
| - **Regular cleanup**: Delete worktrees you're no longer using to save disk space | ||
| - **Commit before deleting**: Always commit and push important changes before deleting a worktree | ||
| - **Use .worktreeinclude**: Set up a `.worktreeinclude` file once and benefit from it for all future worktrees | ||
| - **New windows for parallel work**: Open worktrees in new windows when you want to work on multiple branches simultaneously | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "wheter" should be "whether".
Fix it with Roo Code or mention @roomote and request a fix.