Skip to content

Instantly share code, notes, and snippets.

@toloco
Last active December 27, 2021 15:37
Show Gist options
  • Save toloco/45eec95df0c8fd3d830ebb30fcde7c21 to your computer and use it in GitHub Desktop.
Save toloco/45eec95df0c8fd3d830ebb30fcde7c21 to your computer and use it in GitHub Desktop.
List GIT files and sort by size
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- \
| numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
FILE=foo.json \
git filter-branch -f \
--prune-empty \
--tag-name-filter cat \
--tree-filter 'rm -f $FILE' \
$(git log --follow --find-renames=40% --diff-filter=A --format=%H -- $FILE)~..HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all && git gc --prune=now --aggressive
@toloco
Copy link
Author

toloco commented Jun 8, 2018

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