Skip to content

philstainer/git-worktree

Repository files navigation

Git Worktree

I made this extension because I started using git worktrees and I wanted to make it easier to manage and setup.

There are some sensible defaults but everything is customizable 🥳

Hopefully it helps and enjoy 👋

Features

These are a list of features that I have currently implemented

Clone Command

By default if you use the clone command it create a directory structure like this:

├── .bare
├── .git
├── worktree-1 <--

Then when adding worktrees, they will live along side. This in my opinion is much cleaner and cleaner to manage

clone

Add Command

You can choose to create a new worktree or create one from a remote branch that exists in your repository

Create new worktree
  • Command Palette -> 'Git Worktree: Add'
  • Select 'Create new worktree'
  • Set a name for the worktree
  • Set your tracking branch (think of this as your base branch, normally this is main or master)

add-local

Add remote worktree
  • Command Palette -> 'Git Worktree: Add'
  • Select remote worktree

add-remote

List Command

list

Rename Command

rename

Remove Command

remove

Publish Command

publish

Projects Command

projects

Requirements

  • git

Extension Settings

This extension has the following settings:

General Settings:

Automatically push worktrees to remote

⚠️ **If you turn this off **: Then the tracking branch will not get updated to your new branch and you will have to run the publish command to fix

  • gitWorktree.worktree.shouldPushBranchAutomatically: Yes

Set logging level for extension

  • gitWorktree.worktree.loggingLevel: Info

Should we close prompts when user loses focus

  • gitWorktree.worktree.closeInputOnBlur: True

Clone Settings

Set the name of the folder the bare repository contents will be push into

  • gitWorktree.worktree.cloneBaseDirectory: './.bare'

Should vscode open when clone command has finished

  • gitWorktree.worktree.openOnClone: Yes

Project Settings

Should vscode open when project has been selected

  • gitWorktree.worktree.openOnProject: Yes

Should vscode save your cloned repositories

  • gitWorktree.worktree.saveProjectsAutomatically: No

List Settings

Should vscode open when worktree has been selected

  • gitWorktree.worktree.openOnSwitch: Yes

Add Settings

Set a base directory for worktrees

  • gitWorktree.worktree.baseDirectory: ../

Should include remote branches when creating worktrees

  • gitWorktree.worktree.includeRemote: True

Should prune branches when adding new worktrees

  • gitWorktree.worktree.pruneBranches: False

Should vscode open when worktree has been added

  • gitWorktree.worktree.openOnAdd: Yes

Rename Settings

Should vscode open when worktree has been renamed

  • gitWorktree.worktree.openOnRename: No

Remove Settings

Should rename branch when removing a worktree

  • gitWorktree.worktree.removeBranch: False

Remove worktree command should allow multiple select

  • gitWorktree.worktree.removeMultiple: False

Release Notes

1.0.0

Initial release