Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

disk-cleaner

Recursively scans ~/go/src for git repositories and deletes build artifact directories that are ignored by .gitignore. Also removes any linked git worktrees.

Target directories

Directory Condition
dist Deleted if ignored by .gitignore
bin Deleted if ignored by .gitignore
.go Deleted if ignored by .gitignore
node_modules Deleted if ignored by .gitignore
vendor Deleted if ignored by .gitignore
.cache Deleted if ignored by .gitignore

Install

go install github.com/appscodelabs/disk-cleaner@latest

Or build locally:

go build -o disk-cleaner .

Usage

# Preview what would be deleted and total disk space savings
./disk-cleaner --dry-run

# Delete directories
./disk-cleaner

# Show detailed output
./disk-cleaner --verbose

Flags

Flag Description
--dry-run Preview deletions and show disk space that will be freed
--verbose Print detailed output including skipped directories
-h, --help Show help

How it works

  1. Walks ~/go/src to find git repositories (at depth hosting/org/repo, e.g. github.com/user/repo)
  2. For each repo, lists linked git worktrees (git worktree list) and removes them with git worktree remove --force
  3. Recursively searches the repo for target directories
  4. Uses git check-ignore to verify the directory is listed in .gitignore
  5. Deletes matching directories and worktrees, and reports total disk space freed

Requirements

  • Git must be installed and available on PATH

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages