{"id":13702417,"url":"https://github.com/davidraviv/gh-clean-branches","last_synced_at":"2025-09-06T14:39:45.433Z","repository":{"id":38617218,"uuid":"399725759","full_name":"davidraviv/gh-clean-branches","owner":"davidraviv","description":"Safely deletes local branches with no upstream and no un-pushed commits","archived":false,"fork":false,"pushed_at":"2022-12-26T16:02:05.000Z","size":28,"stargazers_count":180,"open_issues_count":4,"forks_count":17,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-09T01:48:21.055Z","etag":null,"topics":["cli","gh-extension","git-branches","local-environment"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidraviv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"davidraviv","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2021-08-25T07:15:33.000Z","updated_at":"2025-05-02T21:08:10.000Z","dependencies_parsed_at":"2023-01-31T00:25:25.931Z","dependency_job_id":null,"html_url":"https://github.com/davidraviv/gh-clean-branches","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidraviv%2Fgh-clean-branches","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidraviv%2Fgh-clean-branches/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidraviv%2Fgh-clean-branches/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidraviv%2Fgh-clean-branches/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidraviv","download_url":"https://codeload.github.com/davidraviv/gh-clean-branches/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253176440,"owners_count":21866142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","gh-extension","git-branches","local-environment"],"created_at":"2024-08-02T21:00:35.464Z","updated_at":"2025-05-09T01:48:26.683Z","avatar_url":"https://github.com/davidraviv.png","language":"Shell","funding_links":["https://github.com/sponsors/davidraviv"],"categories":["🧩 Categories","Shell","cli","Git","Repo \u0026 Branch"],"sub_categories":["Repository Management"],"readme":"# Clean Branches\n## Description\nGithub CLI extension\n\nSafely delete local branches that have no remotes and no hanging changes.\n\nThe extension uses `git branch -d` to delete the local branches, hence it will not delete branches with un-pushed changes\nunless using `--force` flag.\n\nThe extension supports single or multiple upstream.\n## Installation\n```bash\ngh extension install davidraviv/gh-clean-branches\n```\n\n## Usage\nExecute it inside a git repo folder:\n```bash\ngh clean-branches [--dry-run] [--force] [--verbose]\n```\n### Options\n\n- `--dry-run` See the list of branches to be deleted before actually deleting them.\n- `--force` Uses `git branch -D` forcing a branch to be deleted regardless if upstream branches have local changes. Use carefully!\n- `--verbose` Print all log statements.\n\n## Script flow\n- Fetches the repo\n- Checkout the default branch (e.g `main`) and pull changes (needed if we want to delete the current branch)\n- Lists all remote branches _(only with `--verbose` flag)_\n- Lists all local branches _(only with `--verbose` flag)_\n- Lists branches with missing upstream to be deleted\n- Deletes branches with no upstream and no un-pushed changes _(Skipped on `--dry-run`)_\n- Checkout the branch we started with unless it was deleted, then stays on the default branch\n\n## Dependencies\nThe extension depends on:\n- zsh\n- git v2.22\n- gh CLI v2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidraviv%2Fgh-clean-branches","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidraviv%2Fgh-clean-branches","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidraviv%2Fgh-clean-branches/lists"}