Git worktrees in WebStorm

Answered

I have been trying to configure WebStorm to place nicely with git worktrees. The best advice I can gather is to create a sibling to the project folder, such as` <my-project>_worktrees` and keep the folders in there.

However, still, when attaching these folders in WebStorm, sometimes they are grouped correctly with the project folder, and sometimes they just appear at the top level.

Worse than that, if I do attach a worktree, I have to plan to take a break while WebStorm inexplicably indexes every single file in node_modules – unnecessarily I would say. This process locks up my IDE, making it unusable for about 15 minutes.

It is an awesome product of course, but it baffles me why a process such as indexing is not very low priority background activity that does not prevent the user from continuing to work. Perhaps there is some config I have not come across.

What is the correct procedure when dealing with worktrees?

2
2 comments

What is the correct procedure when dealing with worktrees?

Basically, just create a new worktree for a new or existing branch via command line - e.g. git worktree add -b <worktreeBranch> <WorktreeDirectoryPath>. After that open the <worktreeDirectoryPath> as a project in the IDE. IDE will recognize the project to be a worktree of the original project. Git integration will work as expected.

when attaching these folders in WebStorm, sometimes they are grouped correctly with the project folder, and sometimes they just appear at the top level.

Could you please elaborate a bit more? It would be helpful if you could share a screen recording of the issue in your IDE? You can upload files to our secure server via: https://uploads.jetbrains.com, just provide the uploaded file ID. Thank you!

0

Hi Ivan Pajic,

Thank you for sharing the workaround for opening the IDE in the worktree directory path.

That said, the current workflow feels quite inconvenient. Having to manually open each worktree just to review what Claude, Codex, or other AI tools have developed significantly slows things down. Most of these tools now support parallel local workflows very smoothly, which makes it easy to iterate across multiple branches at once — and that’s extremely useful in practice.

Additionally, when I try to check out an AI-generated branch in the main project folder, I run into error like: Could not checkout origin/codex/my-remote-branch-name: 'codex/my-remote-branch-name' is already used by worktree at '/Users/username/.codex/worktrees/2fe4/projectname'

This makes it difficult to quickly inspect, compare, or continue work in a more flexible way.

Is there a cleaner approach we could adopt that would allow parallel AI workflows without these worktree conflicts?

 

4

Please sign in to leave a comment.