↑ ↓ select, Enter open, Esc close

Find the largest files in the entire Git history

Adjust the values, the command updates live
user@server
git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '$1=="blob"' | sort -k3 -rn | head -n 20

Collects all objects that appear in any commit, queries their size and sorts the files (blobs) in descending order. The columns are type, hash, uncompressed size in bytes and path. Typical finds are accidentally committed database dumps, backups or videos.

Note: Files that have already been deleted show up too, since they still exist in the history. Removing them for good requires rewriting history, for example with git filter-repo.

Also searched as

  • why is my git repository so large
  • find large files in git history
  • git clone takes forever

Related one-liners

All in Git

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.