git-worktree-clean

Fetch from origin and hard-reset a git worktree to a target branch.

1|1|Updated Jun 11, 2024
One-click install
npx skills add https://github.com/ag-grid/ag-shared --skill git-worktree-clean
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-worktree-clean
Source: https://github.com/ag-grid/ag-shared/tree/main/prompts/skills/git-worktree-clean
Command: npx skills add https://github.com/ag-grid/ag-shared --skill git-worktree-clean

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Clean up a worktree by fetching fresh state from origin and hard-resetting to a target branch.

Core Features & Use Cases

  • Recreate a clean worktree by resetting to a target branch
  • Validate current state and ensure origin alignment
  • Use in automation to maintain consistent worktree states

Quick Start

Reset the current git worktree to origin/latest or a specified branch by fetching from origin and performing a hard reset.

Frequently Asked Questions about git-worktree-clean

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I hard reset a git worktree to match origin?

To hard reset a git worktree, fetch the latest state from origin and perform a hard reset to your target branch, aligning the local directory with the remote repository state.

What is the best way to clean up a feature branch worktree with uncommitted changes?

Cleaning up a feature branch worktree requires fetching from origin and executing a hard reset; the process issues warnings about uncommitted changes before proceeding with the deterministic reset.

Can I automate git worktree resets for multiple feature branches?

Yes, you can automate git worktree resets for multiple feature branches to maintain consistent states across development workflows, ensuring each worktree deterministically aligns with its target origin branch.

Does git worktree reset work inside the main repository directory?

No, git worktree reset validation ensures the current directory is a worktree and not the main repo, preventing accidental hard resets of the primary working directory while requiring Git CLI availability.

Why does my git worktree reset fail or warn before discarding changes?

A git worktree reset warns before discarding changes to prevent data loss, checking for uncommitted modifications and validating the worktree state before executing a hard reset to the target branch.