Is there a way to get VS code work with git worktree? (Windows with WSL)
Asked Answered
A

1

9

I like to keep on repository checked out in several worktrees with git worktree to easily work on different branches simultaneously. Yet VS code does not seem to recognize git as scm when it is in a git worktree folder.

I couldn't find anything in the docs about this or an extension. Are there any ideas on how I could get VS code to support git features in an external worktree?

Amazing answered 2/11, 2017 at 13:50 Comment(4)
I hate to be that guy but... "it works for me." Did you open your worktree folder in a new VS Code window? Also, your worktree needs to be in an entirely different directory, outside of your original project directory. (Also, I am using the Insiders version... maybe it's different?)Trager
Oh that seems interesting. I installed Insiders but it didn't work either.Interjection
So... can you describe the full steps of what you are trying?Trager
I have a worktree branch in a subdirectory of master. I needed to create a second Azure Data Studio instance that opened the worktree subdirectory.Alroi
A
13

I didn't think this would matter, but it turns out... I'm on Windows and run my git command line in Windows Subsystem for Linux. But obviously, Git on Windows couldn't find the absolute linux path in /mnt/d....

I replaced it with a relative path and now Git on Linux and Git on Windows both report the worktree as being in a git directory. And it works with VS code as well!

Amazing answered 2/11, 2017 at 15:11 Comment(1)
Scripts to automatically perform this absolute <-> relative conversion are described in this SO answer.Compurgation

© 2022 - 2024 — McMap. All rights reserved.