Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion git-cleaner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ A cross-platform Go CLI tool that scans directories for `.git` directories, repo
- **Size reporting**: Shows disk usage for each repository's `.git` directory
- **Optimization**: Runs `git gc` to optimize repositories and shows disk savings
- **Table output**: Clean, formatted table showing repository paths and sizes
- **JSON output**: Machine-readable output for scripts and CI
- **Config support**: Optional YAML config with default scan path (`--init`, `--config`)

## Installation

Expand Down Expand Up @@ -59,8 +61,14 @@ make build-darwin # macOS builds only

| Flag | Description |
|------|-------------|
| `--scan PATH` | Directory to scan for .git directories (required) |
| `--scan PATH` | Directory to scan for .git directories (overrides config) |
| `--clean` | Run `git gc` in each repository and show disk savings |
| `--yes` | Skip cleanup confirmation prompt |
| `--json` | Output structured JSON (no table/prose on stdout) |
| `--show-pct` | Add `.git` size as % of total repo size |
| `--config PATH` | Config path (default: `~/.config/git-cleaner/config.yaml`) |
| `--init` | Write starter config and exit |
| `--force` | Overwrite existing config when used with `--init` |

## Examples

Expand All @@ -76,6 +84,20 @@ make build-darwin # macOS builds only
./build/git-cleaner --scan ~/projects --clean
```

### Initialize config and scan with defaults

```bash
./build/git-cleaner --init
./build/git-cleaner
```
Comment on lines +89 to +92
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example implies ./build/git-cleaner will work immediately after --init, but the starter config defaults to ~/src and the tool errors if the path doesn’t exist. Consider adjusting the docs to mention editing defaultScanPath (or choosing a more universally-existing default) so users don’t hit a confusing failure after init.

Copilot uses AI. Check for mistakes.

### JSON output for automation

```bash
./build/git-cleaner --scan ~/projects --json
./build/git-cleaner --scan ~/projects --clean --yes --json
```

This will:
1. Scan for all `.git` directories
2. Display their sizes in a table
Expand Down
5 changes: 4 additions & 1 deletion git-cleaner/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module git-cleaner

go 1.21

require github.com/olekukonko/tablewriter v1.1.3
require (
github.com/olekukonko/tablewriter v1.1.3
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/clipperhouse/displaywidth v0.6.2 // indirect
Expand Down
4 changes: 4 additions & 0 deletions git-cleaner/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ github.com/olekukonko/tablewriter v1.1.3/go.mod h1:9VU0knjhmMkXjnMKrZ3+L2JhhtsQ/
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading