A blazingly fast Rust CLI that scans and removes files ignored by .gitignore β interactively and safely.
Installation β’ Features β’ Usage β’ Examples β’ Library
Ever wondered how much disk space those node_modules, target, or .next folders are eating up across your projects? gitclean gives you instant visibility and safe cleanup of all ignored files and directories.
- β‘ Blazingly Fast β Written in Rust with parallel processing
- π― Smart Detection β Recursively respects all nested
.gitignorefiles - π Safe by Default β Preserves secrets like
.envfiles automatically - π Visual Insights β See sizes before you delete
- π¨ Beautiful TUI β Interactive multiselect with sorted results
- π‘οΈ Zero Risk β Review and confirm before any deletion
Install directly from crates.io:
cargo install gitcleanThat's it! Now you can use gitclean anywhere.
| Feature | Description |
|---|---|
| π Recursive Scanning | Collects rules from all .gitignore files in your project tree |
| π― Custom Patterns | Add extra ignore patterns via CLI (-i ".env*,.config*") |
| π Smart Preservation | Automatically protects common secret/config files |
| β‘ Parallel Processing | Lightning-fast size computation with WalkDir + Rayon |
| π¨ Interactive TUI | Beautiful multiselect interface with sizes, sorted descending |
| π Detailed Logging | Informative spinners and progress indicators |
gitclean <PATH> [OPTIONS]<PATH> Project root directory to scan
-i, --ignores <PATTERNS> Extra ignore patterns (comma-separated)
-h, --help Print help information
-V, --version Print version information
gitclean .Output:
π§Ή gitclean v1.0.0
π Root: /home/user/projects/my-app
π Default patterns: 15
π― Extra patterns: 0
β Loading .gitignore files...
β Found 3 .gitignore files
β Scanning ignored items...
β Found 127 ignored items (45 dirs, 82 files)
β Computing sizes...
β Sizes computed
ββββββββββββββββββββββββββββββββββββββββββββ
β Select items to delete (Space to toggle) β
ββββββββββββββββββββββββββββββββββββββββββββ
[ ] node_modules/ 1.2 GB
[ ] target/ 856 MB
[ ] .next/ 234 MB
[ ] dist/ 89 MB
[ ] coverage/ 12 MB
gitclean ~/projects/my-appgitclean . -i ".env*,.config*,*.log"This will additionally ignore:
- All files starting with
.env - All files starting with
.config - All
.logfiles
gitclean provides a delightful CLI experience:
- π Spinner animations while scanning
- π Progress indicators for long operations
- π Organized results sorted by size (largest first)
- β Multi-select interface to choose what to delete
- β Confirmation logs showing freed space
Use gitclean as a library in your own Rust projects:
use gitclean::{
gather_gitignores,
scan_ignored_files,
calculate_sizes,
format_size
};
use indicatif::ProgressBar;
use std::path::Path;
fn main() -> anyhow::Result<()> {
let root = Path::new(".").canonicalize()?;
let spinner = ProgressBar::hidden();
let extra: Vec<String> = vec![];
// Gather all .gitignore rules
let map = gather_gitignores(&root, &spinner, &extra)?;
// Scan for ignored files
let ignored = scan_ignored_files(&root, &map, &spinner)?;
// Calculate sizes
let items = calculate_sizes(ignored, &spinner, &root)?;
println!("Found {} ignored items", items.len());
for item in items {
println!("{}: {}", item.path.display(), format_size(item.size));
}
Ok(())
}gitclean is built with a clean modular structure:
src/
βββ lib.rs β Public API exports
βββ patterns.rs β Default ignore patterns
βββ types.rs β Core types (ItemWithSize)
βββ ignore.rs β .gitignore parsing
βββ scan.rs β Scanning logic
βββ size.rs β Size computation
βββ fsops.rs β File operations
βββ util.rs β Utilities (format_size)
βββ main.rs β CLI interface
Each module is designed to be reusable and testable.
cargo testcargo build --release
./target/release/gitclean .cargo run -- .Contributions are welcome! Here's how you can help:
- π΄ Fork the repository
- πΏ Create a feature branch (
git checkout -b feature/amazing-feature) - πΎ Commit your changes (
git commit -m 'Add amazing feature') - π€ Push to the branch (
git push origin feature/amazing-feature) - π Open a Pull Request
Please read CONTRIBUTING.md and follow the CODE_OF_CONDUCT.md.
MIT Β© 2025 Jordy Fontoura
Made with β€οΈ and π¦ Rust