Skip to content

Instantly share code, notes, and snippets.

@gnomeria
Created March 18, 2020 12:13
Show Gist options
  • Save gnomeria/cd07ebacd1246e26d8829ec19cb05398 to your computer and use it in GitHub Desktop.
Save gnomeria/cd07ebacd1246e26d8829ec19cb05398 to your computer and use it in GitHub Desktop.
Some git commands

Rewrite history to exclude files or folders

git filter-branch -f --index-filter 'git rm -r --cached --ignore-unmatch node_modules/ vendor/' HEAD

List object sizes in git

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 \
| cut --complement --characters=13-40 \
| numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment