Remote GitHub branch cleanup reporting tool
Project description
gh-clean
gh-clean is a remote GitHub branch cleanup tool. It evaluates branches
using GitHub repository state, produces a report, and can delete
branches after re-validating that they are still safe to remove.
Requirements
- Python 3.9+
- GitHub CLI installed
gh auth logincompleted for the target repositories
gh-clean currently uses gh for GitHub API access and authentication.
Install
With uv
Install once:
uv tool install gh-clean
Run without installing globally:
uvx gh-clean report --repo OWNER/REPO
With pipx
pipx install gh-clean
Authenticate
Before using the tool:
gh auth login
If your org requires SAML SSO, authorize the current gh token for that
organization as needed.
Repository config
The target repository must contain a root .gh-clean.yml file with a
non-empty protected_branches list.
Example:
protected_branches:
- main
- staging
- production
This list is checked in addition to GitHub branch protection rules and rulesets.
If you need a one-off run before the config is committed, you can bypass the remote file with a CLI override:
gh-clean report --repo OWNER/REPO --protected-branches main,staging,production
Usage
Generate a report:
gh-clean report --repo OWNER/REPO
gh-clean report --repo OWNER/REPO --format json
gh-clean report --repo OWNER/REPO --protected-branches main,staging,production
Add extra protected branches at runtime:
gh-clean report --repo OWNER/REPO --exclude develop --exclude release/v2
Delete from a prior report with re-validation:
gh-clean report --repo OWNER/REPO --format json > report.json
gh-clean delete --repo OWNER/REPO --input report.json --recommendation delete-candidate --dry-run
gh-clean delete --repo OWNER/REPO --input report.json --recommendation delete-candidate
gh-clean delete --repo OWNER/REPO --input report.json --recommendation delete-candidate --protected-branches main,staging,production
Delete specific branches:
gh-clean delete --repo OWNER/REPO --branch feature/foo --branch feature/bar --dry-run
Override only the merged-tip mismatch soft veto:
gh-clean delete --repo OWNER/REPO --branch feature/foo --force-merged-tip-mismatch --dry-run
Development
Run directly from the checkout:
python3 -m gh_clean report --repo gh-clean-sandbox/sandbox
uv run gh-clean report --repo gh-clean-sandbox/sandbox
Run tests:
python3 -m unittest discover -s tests -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gh_clean-0.1.0.tar.gz.
File metadata
- Download URL: gh_clean-0.1.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7467cf854f78418f63f1c8c14863b643964d29cf27d01a98b001b78847eff6a4
|
|
| MD5 |
cf85cb63e9a86abd1c7984acbfcb29e7
|
|
| BLAKE2b-256 |
953394c7f40964258e105be136cb100977a508bd665b9057eb8a2bda0111c185
|
File details
Details for the file gh_clean-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gh_clean-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9444c44f61e198d45733682f75f419465c5321e385e13460fd377cc38ee89c35
|
|
| MD5 |
8aba17ce82a535cd9554780c432d3a5d
|
|
| BLAKE2b-256 |
a2b46e8f9dea5fb08a3f638e53de717f0eb6a338b62d48527c3bc9b37352faf4
|