Skip to content

Instantly share code, notes, and snippets.

@djeikyb
Last active February 10, 2021 18:18
Show Gist options
  • Save djeikyb/238d13323da3cb0094924bc78999c9b6 to your computer and use it in GitHub Desktop.
Save djeikyb/238d13323da3cb0094924bc78999c9b6 to your computer and use it in GitHub Desktop.
git: find files larger than a megabyte

source: https://stackoverflow.com/a/42544963/659715

Sorts largest files last. First column is the git object id. Second column is size in bytes.

git rev-list --objects --all |
  git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
  sed -n 's/^blob //p' |
  sort --numeric-sort --key=2 |
  cut -c 1-12,41- |
  awk '$2 >= 2^20'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment