{"id":13902538,"url":"https://github.com/agateau/git-bonsai","last_synced_at":"2026-03-18T00:37:19.453Z","repository":{"id":38319056,"uuid":"245716342","full_name":"agateau/git-bonsai","owner":"agateau","description":"Tend the branches of your git garden","archived":false,"fork":false,"pushed_at":"2024-07-05T08:55:16.000Z","size":139,"stargazers_count":21,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T07:54:57.432Z","etag":null,"topics":["branches","clean","command-line","git","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agateau.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-07T22:41:18.000Z","updated_at":"2025-02-08T09:07:00.000Z","dependencies_parsed_at":"2023-01-21T22:45:12.197Z","dependency_job_id":null,"html_url":"https://github.com/agateau/git-bonsai","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateau%2Fgit-bonsai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateau%2Fgit-bonsai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateau%2Fgit-bonsai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateau%2Fgit-bonsai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agateau","download_url":"https://codeload.github.com/agateau/git-bonsai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814907,"owners_count":20352037,"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":["branches","clean","command-line","git","rust"],"created_at":"2024-08-06T22:01:11.773Z","updated_at":"2026-03-18T00:37:14.410Z","avatar_url":"https://github.com/agateau.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Git Bonsai\n\nGit Bonsai is a command-line tool to help you tend the branches of your git garden.\n\n## Usage\n\nJust run `git bonsai` in a git repository checkout.\n\n## What does it do?\n\nGit Bonsai does the following:\n\n1. Fetches remote changes.\n\n2. Iterates on all your local tracking branches and update them to their remote counterparts.\n\n3. Lists branches which can be safely deleted and lets you select the ones to delete.\n\n## Is it safe?\n\nGit Bonsai takes several precautions to ensure it does not delete anything precious:\n\n1. It refuses to run if there are any uncommitted changes. This includes unknown files.\n\n2. It always prompt you before deleting any branch, and explains why this branch is safe to remove.\n\n3. It refuses to delete a branch if it is not contained in another branch.\n\n4. Git Bonsai never touches the remote repository.\n\n## Demo\n\nHere is an example repository:\n\n```\n$ git log --oneline --all --graph\n\n* b87566d (duplicate2, duplicate1) Create duplicate1\n*   e02d47e (HEAD -\u003e master) Merging topic1\n|\\\n| *   020b54c (topic1) Merging topic1-1\n| |\\\n| | * cd060dc (topic1-1) Create topic1-1\n| |/\n| * f356524 Create topic1\n|/\n| * 85a9880 (topic2) Create topic2\n|/\n* 0f209d0 Init\n```\n\n(You can create this repository with the `create-demo-repository` script)\n\n`topic1` and `topic1-1` branches can be safely deleted. `topic2` cannot. One of `duplicate1` and `duplicate2` can also be deleted, but not both.\n\nLet's run Git Bonsai:\n\n```\n$ git bonsai\nInfo: Fetching changes\nThese branches point to the same commit, but no other branch contains this\ncommit, so you can delete all of them but one.\n\nSelect branches to delete:\n\u003e [x] duplicate1\n  [x] duplicate2\n```\n\nI press `Space` to uncheck `duplicate1`, then `Enter` to continue.\n\n```\nInfo: Deleting duplicate2\nSelect branches to delete:\n\u003e [x] topic1, contained in:\n      - master\n      - duplicate1\n\n  [x] topic1-1, contained in:\n      - topic1\n      - duplicate1\n      - master\n```\n\nLooks good to me, so I press `Enter`.\n\n```\nInfo: Deleting topic1\nInfo: Deleting topic1-1\n```\n\nLet's look at the repository now:\n\n```\n$ git log --oneline --all --graph\n\n* 0dfd179 (duplicate1) Create duplicate1\n*   5d06a2d (HEAD -\u003e master) Merging topic1\n|\\\n| *   6a3b1de Merging topic1-1\n| |\\\n| | * 7671947 Create topic1-1\n| |/\n| * c328fee Create topic1\n|/\n| * 1616d9e (topic2) Create topic2\n|/\n* 71913d9 Init\n```\n\n## Installation\n\n### Stable version\n\nThe easiest way to install is to download an archive from the [release page][release], unpack it and copy the `git-bonsai` binary in a directory in `$PATH`.\n\n[release]: https://github.com/agateau/git-bonsai/releases\n\n### Git snapshots\n\nSnapshots from the master branch are available from [builds.agateau.com/git-bonsai](https://builds.agateau.com/git-bonsai).\n\n## Configuration\n\n### Protected branches\n\nGit Bonsai considers branches called `main` and `master` as protected. You can add other protected branches using `git config --add git-bonsai protected-branches \u003cbranch-name\u003e`.\n\n## Building it\n\nGit Bonsai is written in [Rust][]. To build it, install Rust and then run:\n\n```\ncargo install git-bonsai\n```\n\n[Rust]: https://www.rust-lang.org\n\n## Debugging\n\nIf you define the `GB_DEBUG` environment variable, Git Bonsai will print all the git commands it runs.\n\n## Why yet another git cleaning tool?\n\nI created Git Bonsai because I wanted a tool like this but also as a way to learn Rust. There definitely are similar tools, probably more capable, and the Rust code probably needs work, pull requests are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagateau%2Fgit-bonsai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagateau%2Fgit-bonsai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagateau%2Fgit-bonsai/lists"}