A Wrapper for Git Worktree Operations that provides an interactive API so developers can have a better experience.
After creating a ZSH plugin that was responsible for wrapping up my daily git operations(zsh-git-fzf), I found myself very often switching between the terminal and my main Editor(VS Code). So I decided to create an extension for my main Editor that would help me avoid switching between them and keep everything in one tool.
This project supports multiple workspaces, allowing users to organize and manage their projects in separate spaces. If you have opened more than one project, you will be asked to select the workspace in which you want to run the operation. If you have only one project opened, it will be selected as the default workspace.
To select a workspace, simply choose from the list of available workspaces when prompted. Once you've made your selection, the operation will be executed within the chosen workspace.
git worktree add [remote-branch] [new-branch]
Create a new worktree
Behavior
If you do not select a new branch(ESC
), you will create a new worktree with the remote branch you typed. This was made for convenience, instead of having git worktree add master master
, you can just run git worktree add master
.
Since the name of the worktree and branch is the same, we validate the user's new-branch input(Relevant issue)
git worktree list
Display all worktrees and switch between them
git worktree remove [worktree-name]
Remove a worktree
Behavior
Force delete
on the PopupRestrictions
Steps:
CTRL + SHIFT + P
Git Worktree:
Error
If anything goes wrong a Popup will be shown at the bottom left of the screen
If you see anything weird, please open an issue
Property | Type | Default value | Description |
---|---|---|---|
vsCodeGitWorktrees.remove.stalledBranches | boolean | false | Removes local(stalled) branches that do not exist on remote |
vsCodeGitWorktrees.move.openNewVscodeWindow | boolean | true | Open new vscode window when you switch or create a worktree |
vsCodeGitWorktrees.worktrees.dir.path | string | null | Define a directory for all worktrees between your projects |
vsCodeGitWorktrees.add.autoPush | boolean | true | Auto push worktree branch after its creation |
vsCodeGitWorktrees.add.autoPull | boolean | true | Auto pull worktree branch after its creation |
Run the Extension locally
# install dependencies
yarn
# compile code and watch input files
yarn watch
# Then, inside the editor, press F5. This will
# compile and run the extension in a new Extension
# Development Host window.