Git Maintenance Skill
Keep the Shell repo fast and healthy by automating safe Git maintenance.
When to use
- •Periodically (e.g., once a week).
- •After finishing a big feature branch.
- •When Git operations (status, fetch, log) start feeling slow.
Goals
- •Remove stale remote branches.
- •Clean up local merged branches (with your approval).
- •Keep objects packed and repo size under control, without risky operations.
Steps
- •
Show current repo status
- •
Run:
bashgit status git remote -v
- •
Confirm we are in the expected repository (Shell iOS project).
- •
- •
Prune remote tracking branches
- •
Run:
bashgit fetch --prune git remote prune origin
- •
Explain: this removes local references to branches that were deleted on the remote.
- •
- •
Suggest local branch cleanup
- •
List merged local branches:
bashgit branch --merged main
- •
Exclude important branches:
- •
main - •
develop(if it exists) - •Any
epic/*unless user confirms.
- •
- •
Ask the user which merged branches to delete, then run:
bashgit branch -d <branch-name>
- •
- •
Optional: pack objects and clean up
- •
Ask the user if they want to run lightweight garbage collection (or check for
--gcargument):bashgit gc
- •
Explain:
- •This repacks objects and cleans up unnecessary files.
- •Recommended occasionally; avoid
--aggressiveunless repo is extremely large and user explicitly requests it.
- •
- •
Check for large files (optional)
- •
Run a simple size scan, for example:
bashgit rev-list --objects --all | sort -k 2 > /tmp/git-objects.txt
- •
Optionally warn if obviously large binary assets (e.g., > 5–10 MB) are found and suggest:
- •Moving them out of the repo.
- •Or using Git LFS if that ever becomes necessary.
- •
- •
Summarize maintenance
- •Number of remote refs pruned.
- •Local branches deleted.
- •Whether
git gcwas run. - •Any warnings about large files or unusual conditions.