Manage git worktrees with shell scripts for listing, creating, and deleting worktrees.
Manage git worktrees using dedicated shell scripts for listing, creating, and deleting worktrees.
The skill provides three operations:
List worktrees: View all existing worktrees in the repository
scripts/list_worktrees.sh
Create worktree: Create a new worktree with a new branch
scripts/create_worktree.sh <path> <branch-name>
Delete worktree: Remove an existing worktree
scripts/delete_worktree.sh <path>
Display all worktrees in the current repository with their paths and associated branches.
Script: scripts/list_worktrees.sh
Usage:
scripts/list_worktrees.sh
Output: Shows git worktree list with paths, commit hashes, and branch names.
Create a new worktree at a specified path with a new branch. The script ensures the path doesn't exist and the branch name is unique.
Script: scripts/create_worktree.sh
Usage:
scripts/create_worktree.sh <path> <branch-name>
Parameters:
<path>: Directory path where the worktree will be created (e.g., ../feature-x, ~/worktrees/bugfix-123)<branch-name>: Name of the new branch to create (e.g., feature-x, bugfix-123)Validations:
Example:
scripts/create_worktree.sh ../feature-auth feature-auth
Remove an existing worktree from the repository.
Script: scripts/delete_worktree.sh
Usage:
scripts/delete_worktree.sh <path>
Parameters:
<path>: Path to the worktree to delete (must match a registered worktree)Validations:
Example:
scripts/delete_worktree.sh ../feature-auth
All scripts include:
Starting a new feature:
# Create worktree for new feature
scripts/create_worktree.sh ../feature-user-profile feature-user-profile
# Work in the new worktree
cd ../feature-user-profile
# ... make changes, commit, push ...
# Return to main worktree
cd -
# Clean up when done
scripts/delete_worktree.sh ../feature-user-profile
Viewing all active worktrees:
scripts/list_worktrees.sh