VS Code Git Worktrees
A Wrapper for Git Worktree Operations that provides an interactive API so developers can have a better experience.
Links
Purpose of the extension
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.
Requirements
- Git version: 2.34.1
Supported operations
-
git worktree add [new-branch] [remote-branch]
Create a new worktree
Behavior
- If you do not select a remote branch(
ESC
), you will create a new worktree with the new branch you typed. This was made for convenience, instead of havinggit worktree add master master
, you can just rungit worktree add master
.
- If you do not select a remote branch(
-
git worktree list
Display all worktrees and switch between them
-
git worktree remove [worktree-name]
Remove a worktree
Behavior
- If you have untracked or modified files a Popup will be shown at the bottom left of the screen.
- If you want to force delete the worktree with the untracked or modified files, just click
Force delete
on the Popup
- If you want to force delete the worktree with the untracked or modified files, just click
Restrictions
- You cannot delete the same Worktree as the one you are currently working on
- If you have untracked or modified files a Popup will be shown at the bottom left of the screen.
Getting started
Steps:
- Install Git Worktree VS Code extension
- Open the palette:
CTRL + SHIFT + P
- Search for any available operations
- Prefix:
Git Worktree:
- Prefix:
Features/Operations/Error
If you are not able to see the GIFs in the post, take a look at GitHub README and open each GIF in a new tab.
- Worktree Add (Create)
- Worktree List (Switch)
- Worktree Remove
-
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
Properties
Property | Type | Default value | Description |
---|---|---|---|
vsCodeGitWorktrees.remove.stalledBranches | boolean | false | Removes local(stalled) branches that do not exist on remote |
Contribution
- Reporting a bug
- Improving this documentation
- Writing tests
- Sharing this project and recommending it to your friends
- Giving a star on this repository
- TODO
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.
Top comments (0)