vscode-git-graph
vscode-git-graph copied to clipboard
Open workspace/folder from Git worktree
Hi,
It would be useful to have a function to jump to another VS Code workspace/folder in another Git worktree. If possible it should create worktree when it does not exist using path format from settings.
In our company we have code targeting different platforms in different branches and switching between them is cumbersome: check if worktree exists, if not create worktree, then use VS Code's File -> Open Workspace from File... or File -> Open Folder... to open workspace. It simply could be done from Git Graph commit list - right click commit and click on "Checkout..." and have option to checkout a worktree or if worktree already exists have something similar to git tags but representing worktrees.
Usual path format we use is {Repo}_{Branch}, e.g. C:/Softera/Git/org/project/MyRepo_MyBranch.
Format setting could use Regex rename rule to get worktree path from original repo path and branch, something like "${Path}_${Branch:[^\w]/_/}"
(inspired by VS Code snippet transforms).
Worktree icon would be shown next to branch name.
Right clicking the folder icon should show possible actions:
- Create Git worktree if it does not exist (worktree creation dialog should show where)
- Open Git worktree as a folder
- Open CodeWorkspace1.code-workspace (if exists)
- Open CodeWorkspace2.code-workspace (if exists)
Also there is a nuance that same branch cannot be used in multiple worktrees, but commit IDs and tags (worktree refers to commit ID) can. So I guess worktree icon could also stand alone on the commit line.
Thanks.