Bash scripts to maintain and optimize your development environment by cleaning up Git repositories and old log files.
This project provides two scripts to keep your development workspace clean and optimized:
- Git Repository Optimization: Runs
git gcon all repositories to reclaim disk space - Log File Cleanup: Removes old log files based on age criteria
Recursively finds all Git repositories in a directory and optimizes them using git gc --aggressive.
Removes old files from common log directories (log, logs, tmp and temp) based on modification time.
-
Clone or download the scripts to your local machine:
curl -O https://raw.githubusercontent.com/fabioboris/cleanup-scripts/refs/heads/main/cleanup-git.sh curl -O https://raw.githubusercontent.com/fabioboris/cleanup-scripts/refs/heads/main/cleanup-logs.sh
-
Make them executable:
chmod +x cleanup-git.sh cleanup-logs.sh
-
Optional: Move to a directory in your PATH:
sudo mv cleanup-*.sh /usr/local/bin/
# Clean current directory
./cleanup-git.sh
# Clean specific directory
./cleanup-git.sh /path/to/projects
# Quiet mode (minimal output)
QUIET=true ./cleanup-git.sh /path/to/projects# Default cleanup (30 days)
./cleanup-logs.sh /path/to/projects
# Custom retention period
./cleanup-logs.sh -d 7 /path/to/projects
# Using environment variable
DAYS=15 ./cleanup-logs.sh /path/to/projects
# Show help
./cleanup-logs.sh -h- Bash 4.0 or higher
- GNU findutils (for
-print0and-deleteoptions) - Git (for repository cleanup)
- Unix-like system (Linux, macOS, WSL)
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Test your changes thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.