{"id":22268244,"url":"https://github.com/stefanopisano/git-cleanup","last_synced_at":"2026-05-15T18:34:11.025Z","repository":{"id":65486203,"uuid":"593169304","full_name":"StefanoPisano/git-cleanup","owner":"StefanoPisano","description":"Simple shell script to clean GIT repositories","archived":false,"fork":false,"pushed_at":"2024-11-20T11:55:23.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-09T19:18:46.278Z","etag":null,"topics":["git","repository","shell","shell-script","utilities"],"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/StefanoPisano.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}},"created_at":"2023-01-25T12:00:46.000Z","updated_at":"2024-11-20T11:55:27.000Z","dependencies_parsed_at":"2024-11-20T21:52:06.046Z","dependency_job_id":null,"html_url":"https://github.com/StefanoPisano/git-cleanup","commit_stats":null,"previous_names":["stefanopisano/git-cleanup"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/StefanoPisano/git-cleanup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoPisano%2Fgit-cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoPisano%2Fgit-cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoPisano%2Fgit-cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoPisano%2Fgit-cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefanoPisano","download_url":"https://codeload.github.com/StefanoPisano/git-cleanup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoPisano%2Fgit-cleanup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33074861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["git","repository","shell","shell-script","utilities"],"created_at":"2024-12-03T11:12:02.242Z","updated_at":"2026-05-15T18:34:11.005Z","avatar_url":"https://github.com/StefanoPisano.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Git Cleanup\n\n### Overview\nThis Bash script automates the process of cleaning up remote branches in a Git repository. It identifies branches merged into the main branch, filters them based on predefined patterns, and generates a report with commands to delete them. If executed with the `execute` argument, it performs the branch cleanup automatically.\n\n---\n\n### Features\n- **Fetch Updates:** Retrieves the latest changes from the remote repository.\n- **Merged Branch Report:** Generates a list of branches merged into the main branch.\n- **Filtering:** Excludes specific branches and patterns (e.g., `master`, `main`, `HEAD`, `develop`, `release`).\n- **Command Generation:** Prepares `git push --delete` commands for branch cleanup.\n- **Execution Mode:** Optionally executes the cleanup commands.\n\n---\n\n### Prerequisites\n1. Ensure Git is installed and configured on your system.\n2. Verify that you have appropriate permissions to delete branches on the remote repository.\n3. Update the `project_dir` variable in the script to point to your Git project directory.\n\n---\n\n### Usage\n1. **Clone or Download the Script**  \n   Save the script to your desired location and make it executable:\n   ```bash\n   chmod +x git-cleanup.sh\n   ```\n\n2. **Run the Script**  \n   Execute the script without arguments to generate a report only:\n   ```bash\n   ./git-cleanup.sh\n   ```\n\n   To generate the report and delete branches:\n   ```bash\n   ./git-cleanup.sh execute\n   ```\n\n---\n\n### Script Workflow\n1. **Fetch Updates:** Updates local information from the remote repository.\n2. **Create Timestamped Directory:** Organizes output files in a uniquely named folder.\n3. **List Merged Branches:** Identifies branches merged into the main branch (`main` by default).\n4. **Filter Branches:** Excludes unwanted branches and release-related branches.\n5. **Generate Cleanup Commands:** Writes `git push --delete` commands to a final report.\n6. **Execute Commands (Optional):** Deletes branches if `execute` is passed as an argument.\n\n---\n\n### Output\n- **`original-report.txt`:** Full list of merged branches.\n- **`pre-final-report.txt`:** Filtered list of branches.\n- **`final-report.txt`:** Commands to delete branches.\n\n---\n\n### Configuration\nYou can customize the following variables:\n- **`project_dir`:** Path to your Git project.\n- **`branches_to_filter`:** Branch patterns to exclude.\n- **`main_branch`:** The main branch used for comparison (default: `main`).\n\n---\n\n### Error Handling\n- The script will display error messages in red if it encounters issues like missing directories or commands failing.\n- Each step is logged with a descriptive message for better traceability.\n\n---\n\n### Example\n```bash\n# Run script in preview mode (generates report only):\n./git-cleanup.sh\n\n# Run script and execute branch cleanup:\n./git-cleanup.sh execute\n```\n\n---\n\n### Notes\n- The script should be run from a directory where it has write permissions.\n- Use caution when running with the `execute` option, as it will permanently delete branches.\n\n---\n\n### License\nThis script is provided \"as-is\" without any warranty. Use at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanopisano%2Fgit-cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanopisano%2Fgit-cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanopisano%2Fgit-cleanup/lists"}