Developer builds single-file Python tool to identify and explain stale Git branches
A software developer created a lightweight command-line tool called git-stale after discovering over 40 accumulated local branches in an older repository, most of which were obsolete. The tool, written as a single Python file under 6KB, requires no third-party dependencies and works with Python 3.8 and Git. It flags branches as stale based on three checks: whether they are fully merged into the default branch, whether their remote upstream has been deleted, or whether their last commit exceeds a configurable age threshold (30 days by default). Unlike built-in Git commands such as git branch --merged or git branch -vv, the tool provides a per-branch reason for deletion rather than a bare list, and automatically excludes the currently checked-out branch to prevent accidental self-deletion. The developer intentionally kept the tool dependency-free, reasoning that a cleanup utility requiring its own install process would simply never get used.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in