Skip to main content

git-worktree-tidy

Fetch latest from origin, prune remote-tracking refs, delete stale local branches and worktrees, and fast-forward important branches. Use when tidying up a worktree-based repo layout.

소스 정보

저장소
NeverSight/learn-skills.dev
최근 소스 활동
2026년 8월 6일 03:19
감지된 SKILL.md 언어
영어
스타
218
포크
38

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

파일 탐색기
13 개 파일

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
git-worktree-tidy
description
Fetch latest from origin, prune remote-tracking refs, delete stale local branches and worktrees, and fast-forward important branches. Use when tidying up a worktree-based repo layout.
metadata
{"short-description":"Worktree hygiene cleanup"}
# git-worktree-tidy Routine hygiene for bare-repo + worktree layouts. Fetches origin, prunes gone branches and orphaned worktrees, and fast-forwards important local branches. ## When to use User asks to "fetch prune", "clean up stale branches/worktrees", or "update main/dev to latest" in a worktree-based repo. ## Hard Rules - All destructive actions (worktree remove, branch delete) require user confirmation. Present the full list and wait. - Never force-delete a worktree with uncommitted changes without explicit approval. Flag dirty worktrees separately. - Use `--ff-only` when updating branches. If ff-only fails, stop and ask. - Operate from the `.bare` directory (or repo root) for branch/worktree management commands. ## Workflow ### 1) Locate the bare root Determine the bare repo directory: - If cwd contains `.bare/`, use it - Otherwise: `git rev-parse --git-common-dir` All branch and worktree management commands run from this directory. ### 2) Fetch + prune ```bash git fetch --prune origin ``` Report what was pruned (deleted remote-tracking branches, updated refs). ### 3) Discover stale branches ```bash git branch -vv | grep ': gone]' ``` Collect branch names whose upstream is gone. ### 4) Discover stale worktrees ```bash git worktree list git worktree prune --dry-run ``` Cross-reference worktrees against the gone-branch list. Check each stale worktree for dirty state: ```bash cd <worktree-path> && git status --short ``` Categorize: - **Clean + gone**: safe to remove - **Dirty + gone**: flag for user review - **Prunable metadata**: orphaned worktree entries (directory already gone) ### 5) Confirm deletions Present a summary table: ``` Stale worktrees to remove: <path> (<branch>) [clean] <path> (<branch>) [dirty — N uncommitted changes] Stale branches to delete: <branch> Prunable worktree metadata: <entry> ``` Wait for user confirmation before proceeding. ### 6) Remove stale worktrees For each confirmed worktree: ```bash git worktree remove <name> ``` If removal fails (dirty), report and skip unless user approved force. ### 7) Delete stale branches ```bash git branch -D <branch1> <branch2> ... ``` ### 8) Prune worktree metadata ```bash git worktree prune -v ``` ### 9) Update important branches Identify which branches have dedicated worktrees for `main`, `dev`, or other important branches (user may specify). For each: ```bash cd <worktree-path> && git pull --ff-only origin <branch> ``` If ff-only fails, report the divergence and ask for guidance. ### 10) Final status Show a summary: what was removed, what was updated, any items skipped.
GitHub에서 보기