A simple CLI tool written in Go to identify and optionally delete stale local Git branches that no longer exist on the remote. Keeps your local Git repo clean and manageable.
- 🔍 Detects stale local branches by comparing against a remote
- 🗑️ Optionally delete stale branches via
--delete - 🌐 Supports custom remotes (default:
origin) - ⚙️ Pure Go with minimal code and no dependencies
- 🔒 Never deletes
mainormasterbranches
go install github.com/hadzicni/gitclean-cli/cmd/gitclean@latestMake sure $GOPATH/bin is in your $PATH.
git clone https://github.com/hadzicni/gitclean.git
cd gitclean/cmd/gitclean
go build -o gitclean.exegit clone https://github.com/hadzicni/gitclean.git
cd gitclean/cmd/gitclean
go build -o gitcleangitclean [flags]| Flag | Description |
|---|---|
--delete, -d |
Delete all stale local branches |
--remote, -r |
Specify remote to compare against (default: origin) |
List stale branches:
gitcleanList using a custom remote:
gitclean -r upstreamDelete all stale branches:
gitclean -dMade by Nikola Hadzic
GitHub: @hadzicni
This project is licensed under the Apache License 2.0. See the LICENSE file for details.