How to work with Git worktree in VS-code?
Asked Answered
G

1

13

Something I'm having a hard time to understand:

how do I work with git worktrees in VS-code ?

I apparently cannot make it work.

I've tried using the command line ... but then when I try to checkout to the desired branch, it tells me:

Error: Command failed: C:\Program Files\Git\cmd\git.exe -c core.longpaths=true -c core.quotepath=false -c color.ui=false checkout sequences --

fatal: 'sequences' is already checked out at

and when I change folder in command line like on so many videos (outside of vs-code) ... it stays with the same branch check-out.

Can somebody help me out or point me to a resource / blog that indicate how to proceed or how to configure to get git worktree working with vs-code ?

Gimble answered 10/12, 2021 at 17:18 Comment(1)
A branch can only be checked out in a single worktree. Find which of your worktree has the branch checked out and switch to another branch.Geraint
A
2

you can check this issue for your question https://github.com/microsoft/vscode/issues/68038 from terminal you can work

working with git worktree...

git --bare
git worktree list
git worktree add <branch>
git worktree remove <branch>
...

further...

https://git-scm.com/docs/git-worktree#:~:text=In%20its%20simplest%20form%2C%20git,at%20path%20..%2Fhotfix%20.

Attaway answered 29/5, 2022 at 13:48 Comment(3)
thanks to you, I think I identified exactly my issue: github.com/microsoft/vscode/issues/140790Gimble
I'll probably need to wait the next release to see a difference ... and start being able to use worktreesGimble
I tried from terminal. Now after creating the worktree, I can navigate to it ... everything seem to work in the command line as expected ... except that the rest of the vs-code display keeps displaying what is on the main branch, and not at all what is in the worktree branch. That is extremely awkward. Do you have a way to switch the focus of the VS-code display on the content of the worktree branch? or do I have to wait for a future release to solve this issue?Gimble

© 2022 - 2024 — McMap. All rights reserved.