Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

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