Small disclaimer: AI was used to polish the description of this issue from my rough notes
Summary
First of all, thanks for this tool, it’s become part of our daily workflow and has been working really well for us 🙌
When using gtr editor or gtr create --editor, gtr currently opens the worktree directory directly in the editor. However, editors like VS Code and Cursor support .code-workspace files, which allow defining multi-root workspaces, editor settings, and recommended extensions.
Context
At work, we rely heavily on .code-workspace files to ensure projects open with the correct structure and configuration. Most of our repositories already include one at the root for this reason.
Problem
Even when a .code-workspace file is present, gtr always opens the folder itself. This means we have to manually open the workspace file every time after the editor launches, which breaks the otherwise smooth workflow.
Proposed Solution
Add support for opening workspace files when launching an editor:
-
Config option
Allow specifying a workspace file via configuration, e.g. gtr.editor.workspace (or defaults.workspace in .gtrconfig), resolved relative to the worktree root.
-
Auto-detect fallback
If no config is set, automatically look for a *.code-workspace file in the worktree root and use it if found.
Example
# Configure a specific workspace file
git gtr config set gtr.editor.workspace "project.code-workspace"
# Or in .gtrconfig
[defaults]
workspace = project.code-workspace
When opening a worktree, the editor would receive the workspace file path instead of the folder, for example:
cursor project.code-workspace instead of cursor /path/to/worktree
Notes / Constraints
- Only applies to editors that support workspace files (VS Code, Cursor)
- Workspace paths are resolved relative to the worktree root
- Falls back to opening the folder if the workspace file doesn’t exist
- Likely requires changes in:
- adapters/editor/cursor.sh
- adapters/editor/vscode.sh
Affected Commands
git gtr create --editor
git gtr editor <id>
Next Steps
If this is something the team would be interested in, I’m happy to open a PR in the next few days to implement it.