← ClaudeAtlas

git-opslisted

Git hygiene: clean up merged branches, prune stale remotes, and verify repository state.
rube-de/cc-skills · ★ 10 · Code & Development · score 75
Install: claude install-skill rube-de/cc-skills
# DLC: Git Ops Automated git hygiene — clean up merged branches, prune stale remote tracking refs, and verify repository state. ## Step 1: Sync with Remote Fetch latest state, prune deleted remote branches, and sync the default branch. ```bash # Detect the default branch dynamically # 2>/dev/null suppresses errors when symbolic-ref is not set (e.g. shallow clone) DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||') # Fallback: check for main, then master if [ -z "$DEFAULT_BRANCH" ]; then if git show-ref --verify --quiet refs/remotes/origin/main; then DEFAULT_BRANCH="main" elif git show-ref --verify --quiet refs/remotes/origin/master; then DEFAULT_BRANCH="master" else echo "ERROR: Cannot determine default branch. Aborting." exit 1 fi fi echo "Default branch: $DEFAULT_BRANCH" # Fetch and prune stale remote tracking refs git fetch origin --prune # Abort if worktree has uncommitted changes if [ -n "$(git status --porcelain)" ]; then echo "ERROR: Worktree is dirty — stash or commit your changes before running git-ops." exit 1 fi # Capture starting branch before switching — Step 3 uses this for the commit range START_REF=$(git branch --show-current) # Switch to default branch and pull (fast-forward only to avoid merge commits) git checkout "$DEFAULT_BRANCH" git pull --ff-only origin "$DEFAULT_BRANCH" ``` If `git pull --ff-only` fails, abort with: "ERROR: non-fast-forward update for $DEFAULT_B