What this prompt does
This prompt audits and optimizes a bloated Git repository that has grown to [repo_size] with [branch_count] branches. It produces commands to find large files in history using git-filter-repo, a script to safely delete merged branches older than [stale_branch_age], steps to squash old history while preserving the recent [keep_months] months, and a .gitignore audit for [language] projects. It also covers a Git LFS migration plan for your [large_file_types] and CI-friendly shallow clone and sparse checkout configs.
The structure works because it pairs aggressive cleanup with strict safety. History rewrites with git-filter-repo are unforgiving once they touch shared history, so the prompt insists on dry-run options and safety checks for every destructive operation. By adding pre-commit hooks to block future large-file commits, it not only slims the repo today but stops it from ballooning again from committed binaries and dead branches. It also addresses CI clone times directly with shallow clone and sparse checkout configurations, which is often where bloat hurts most: every pipeline run pays the cost of a fat history. The combination of a one-time cleanup and ongoing guardrails is what keeps the repo lean instead of slipping back to [repo_size] a year later.
When to use it
- Clone times are crawling because the repo has grown to
[repo_size]from committed binaries. - You have
[branch_count]branches and need to safely prune ones merged over[stale_branch_age]ago. - You want to move
[large_file_types]into Git LFS instead of bloating history. - Your CI is slow and could benefit from shallow clones or sparse checkout.
- You need a
.gitignoreaudit so the same[language]build artifacts stop getting committed. - You want pre-commit hooks that block large files before they ever enter history.
Example output
Expect a cleanup playbook: git-filter-repo commands to locate and strip large files, a branch-pruning script honoring [stale_branch_age], history-squash steps that keep the last [keep_months] months, a .gitignore audit for [language], an LFS migration plan for [large_file_types], and CI shallow-clone/sparse-checkout configs. Every destructive step is presented with dry-run options and safety checks so you can preview before committing.
Pro tips
- Always run history rewrites with the provided dry-run flags first and take a full backup, because git-filter-repo cannot be undone once it touches shared history.
- Coordinate with your team before rewriting history, since everyone must re-clone afterward and stale forks will conflict.
- Be specific about
[large_file_types]so the LFS migration targets the right binaries instead of sweeping in source files. - Set
[keep_months]to a window that preserves meaningful blame and bisect history, not just the last few weeks. - Tune
[stale_branch_age]conservatively at first so you do not delete branches someone is quietly still using. - Iterate by running the large-file report, reviewing the candidates, and only then applying the rewrite.