A safe, selective cleanup tool for Git repos with stash-first protection and cross-platform support
Visit Project Git Fresh is a cross-platform CLI tool that safely resets Git repositories to a clean state while selectively preserving environment files and untracked changes. It’s designed with rollback safety, non-destructive principles, and full support for .env file detection, stash-first workflows, and fine-grained cleanup logic.
My Role in the Project
As the creator and only developer, I:
- Designed the full security-first architecture, prioritizing stash-based recovery and selective deletion.
- Implemented cross-platform cleanup logic, supporting path normalization and safe file operations.
- Built interactive CLI flows using Inquirer.js and Commander.js.
- Optimized performance with parallel glob processing and error-tolerant file deletion.
Technical Details and Interesting Aspects
File Protection & Options
.envand custom glob patterns are detected and protected by default.- Offers selective preservation via interactive prompts.
- CLI flags include
--ignoreEnvFiles,--ignoreGlobFiles,--skipConfirmation.
Cleanup Logic
- Uses
rmSync(..., { recursive: true, force: true })for efficient removal. - Operates with a non-destructive stance:
.git/and protected files are never touched. - Generates unique sets from normalized paths to avoid redundant checks.
Git Integration
-
Automatically stashes all changes before cleanup.
-
Commands used:
git stash push -u -m "git-fresh: temporary stash"git restore .andgit stash popgit stash listfor rollback support
User Interaction
-
Uses
inquirerprompts to allow:- Full skip, selective, or no preservation of
.envfiles. - Checkbox selection for granular control.
- Full skip, selective, or no preservation of
-
Visual progress via
oraspinners.
Error Handling
- Gracefully aborts if stash fails.
- Conflicts or restore issues are logged, stash is preserved.
- All file-related warnings are non-blocking.
Platform Support
- Path normalization supports mixed separators (
/,\). windowsHide: trueavoids flashing terminals on Windows.- Compatible with macOS, Linux, and Windows environments.
Development Tooling
- Written in TypeScript, built to CommonJS with Bun.
- CLI framework: Commander.js
- Testing via manual repos + interactive workflows.
- Linting and formatting with Prettier.
- Published to npm with provenance enabled.
Conclusion
Git Fresh is a highly practical CLI tool that turns error-prone manual cleaning into a safe, repeatable operation. Its architecture reflects my focus on developer safety, DX-first interfaces, and reliability across all environments.