{"id":29195486,"url":"https://github.com/piyook/gitcrop","last_synced_at":"2025-07-02T05:04:34.203Z","repository":{"id":295982226,"uuid":"991918368","full_name":"piyook/gitcrop","owner":"piyook","description":"A command line utility to SAFELY batch delete all local git branches that match a supplied pattern ","archived":false,"fork":false,"pushed_at":"2025-06-04T14:33:37.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-04T21:03:57.243Z","etag":null,"topics":["bash-script","branches","git"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piyook.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-28T10:47:12.000Z","updated_at":"2025-06-04T14:33:39.000Z","dependencies_parsed_at":"2025-05-28T11:40:46.986Z","dependency_job_id":"6e421a41-c796-41b1-81a5-aca048025359","html_url":"https://github.com/piyook/gitcrop","commit_stats":null,"previous_names":["piyook/gitcrop"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/piyook/gitcrop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piyook%2Fgitcrop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piyook%2Fgitcrop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piyook%2Fgitcrop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piyook%2Fgitcrop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piyook","download_url":"https://codeload.github.com/piyook/gitcrop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piyook%2Fgitcrop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263077630,"owners_count":23410167,"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":["bash-script","branches","git"],"created_at":"2025-07-02T05:04:32.910Z","updated_at":"2025-07-02T05:04:34.186Z","avatar_url":"https://github.com/piyook.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub Release](https://img.shields.io/github/v/release/piyook/gitcrop)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n# Gitcrop: A Branch Batch Deletion Command Line Utility for Git Repositories :scissors:\n\nLets face it - old redundant branches can quickly start to get out of hand and clog up your local repo. :face_with_spiral_eyes:\n\nTidying up a local repo by deleting branches one by one can be a real pain and using the usual Git command can mean accidentally deleting the wrong branch or deleting a branch you don't want to delete. :cursing_face:\n\nGit Crop is a simple bash script that allows you to safely delete all branches matching a given pattern in a LOCAL git repository with a single command.\n\nThe search pattern automatically excludes protected branches such as the default ('main' or 'master') branch and any 'develop' branches to prevent deleting them by accident. Other protected branches patterns can be added into the EXCEPTIONS variable command in the script.\n\nThis script is easier and safer than using the usual Git command below:\n\n```bash\ngit branch -D $(git branch --list 'pattern/*')\n```\n\n## Usage\n\nTo use Git Crop, simply run the script in a Git repo with the pattern you want to match as an argument. For example:\n\n```bash\ngitcrop feature/\n```\n\nThis will delete all branches in the current Git repo that match the pattern \"feature/\" first listing them and checking you want them deleted before deleting them.\n\nTo delete ALL branches except protected ones ('main' or 'develop') use --nuke option :bomb: :bomb: :boom:\n\n```bash\ngitcrop --nuke\n\nWARNING: The following branches will be PERMANENTLY deleted:\n  chore/apply_patch-2\n  chore/pr-21\n  test/test-1\n  feat/jira-123/new-options\n  fix/jira-125/comments\n  pr-22\nAre you sure? (y/n)\n```\n\n## Options\n\n- use '--help' or '-h' to display a help message\n- use '--nuke' to delete ALL local branches except 'main' or 'develop'\n- use '--merged' or '-m' to only delete branches MERGED into main (or master) branch matching the supplied pattern\n\n\u003ci\u003eNote: branches that are newly created from the main branch with no new commits that match the search pattern will also be deleted since they are fully merged by default.\u003c/i\u003e\n\nE.g\n\n```bash\ngitcrop feature/ --merged\n```\n\nwill only delete branches merged into main (or are identical) that match the pattern 'feature/'\n\n## Installation\n\nTo install Git Crop, simply copy the script to a directory on your PATH and make it executable.\n\n### Linux / Mac / WSL:\n\n1. Run the setup script:\n\n```bash\nbash setup_linux.sh\n```\n\n2. Check it works:\n\n```bash\nsource ~/.bashrc\n\ngitcrop --help\n```\n\n### Windows Powershell:\n\nSetup using WSL with your distro of choice as above for Linux and then:\n\n1. Use Powershell to copy the gitcrop.bat batch file to any suitable location specified in your PATH E.g: C:\\Windows\n\n```PowerShell\nMove-Item gitcrop.bat C:\\Windows\n```\n\n2. Check it works:\n\n```PowerShell\ngitcrop --help\n```\n\n### Note for Git Bash on Windows:\n\n1. Run the setup script:\n\n```bash\nbash setup_gitbash.sh\n```\n\nThis creates a Scripts directory in the user's home directory (if one doesn't already exist) and copies the gitcrop.sh script into it, makes it executable and adds an alias for easy access.\n\n2. Check it works:\n\n```bash\nsource ~/.bashrc\n\ngitcrop --help\n```\n\n## License\n\nThis script is released under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiyook%2Fgitcrop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiyook%2Fgitcrop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiyook%2Fgitcrop/lists"}