Why your disk cleanup tool shouldn't use rm -rf
Описание и применение
Переход от простого rm -rf к командам очистки, специфичным для каждой сборки, предотвращает потерю данных и сохраняет git‑историю, одновременно освобождая место на диске.
Задача
Deleting build output by name with rm -rf can accidentally remove important files, git‑tracked artifacts, or shared resources, leading to data loss and wasted rebuilds.
Результат
Switching from blind rm -rf to tool‑specific clean commands prevents accidental data loss, preserves git history, and maintains shared caches, while still reclaiming disk space efficiently.
Рабочий процесс
- Identify the project type and its build output directories.
- Run the appropriate tool‑specific clean command (e.g., cargo clean, flutter clean, ./gradlew clean).
- If the SDK is not installed, confirm the directory name is on a safe allow‑list and that deletion is intentional.
- Execute rm -rf only after confirmation and when no git‑tracked files or shared symlinks are present.
- Verify the directory is removed and the project rebuilds correctly.
- Optionally use Kruftle to automate the process across nested projects.
- Report the actual freed space after cleanup.
Доказательства
This is the one that actually cost me something. Some repositories commit their build output deliberately…
Running cargo clean instead of deleting target/ by hand doesn't require any cleverness on your part.
- Дата записи: 2026-09-10T16:04:05.493Z