gitclean
A fast Rust CLI to scan and clean files and directories ignored by .gitignore across your project. It detects ignored items, shows sizes, and lets you interactively delete them.
Features
- Recursively collects .gitignore rules (supports nested .gitignore)
- Extra ignore patterns via CLI (
-i ".env*,.config*") - Preserves common secret/config files by default (negated patterns)
- Parallel size computation (WalkDir + Rayon)
- TUI multiselect (inquire) with sizes, sorted descending
- Informative spinners and logs (indicatif + console)
Install
Build from source:
Or build a release binary:
Usage
Examples:
# Current directory
# Custom root path
# Add extra ignore patterns (comma-separated)
Logs & UX
- Startup header: shows version, root, default and extra pattern counts
- Spinners for: loading .gitignore, scanning ignored items, computing sizes
- Summary after scanning: total ignored (dirs/files)
- Deletion logs include size per item
Library usage
Core logic is exposed as a library for reuse:
use ;
use ProgressBar;
use Path;
let root = new.canonicalize.unwrap;
let spinner = hidden;
let extra: = vec!;
let map = gather_gitignores?;
let ignored = scan_ignored_files?;
let items = calculate_sizes?;
println!;
Module layout
src/lib.rs: public re-exportssrc/patterns.rs: default ignore patternssrc/types.rs: shared types (ItemWithSize)src/ignore.rs: .gitignore loading (gather_gitignores)src/scan.rs: scan logic (scan_ignored_files,is_path_ignored)src/size.rs: size computation (calculate_sizes)src/fsops.rs: file ops (remove_item)src/util.rs: helpers (format_size)src/main.rs: thin CLI using the library
Development
# Run tests
# Build release
Contributing
Contributions are welcome! Please read CONTRIBUTING.md and follow the CODE_OF_CONDUCT.md.
License
MIT © 2025 Jordy Fontoura