Skip to content

Instantly share code, notes, and snippets.

@evgv
Created April 26, 2017 06:21
Show Gist options
  • Select an option

  • Save evgv/a959a7dbd537db27deb855db52e0841b to your computer and use it in GitHub Desktop.

Select an option

Save evgv/a959a7dbd537db27deb855db52e0841b to your computer and use it in GitHub Desktop.
Git. Find/identify large files/commits in Git history

Find/identify large files/commits in Git history

The Base Code

This bash one-liner displays all blob objects in the repository, with the largest ones last.
This will generate computer-friendly output.

    git rev-list --objects --all \
  | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
  | awk '/^blob/ {print substr($0,6)}' \
  | sort --numeric-sort --key=2

Output for Humans

If you append the following to the above code you get beautiful human-readable output

    | cut --complement --characters=8-40 \
    | numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest

More here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment