Skip to content

Instantly share code, notes, and snippets.

@vepetkov
Last active February 2, 2024 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vepetkov/e3c66dd2a8c10b2f951a001684ebb737 to your computer and use it in GitHub Desktop.
Save vepetkov/e3c66dd2a8c10b2f951a001684ebb737 to your computer and use it in GitHub Desktop.
# Parse the whole git history and show files larger than 1Mb (2^20 b)
git rev-list --objects --all |
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
sed -n 's/^blob //p' |
awk '$2 >= 2^20' |
sort --numeric-sort --key=2 |
cut -c 1-12,41- |
$(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
# Show full history of commits that changes a file / path
git log --full-history -- [file path]
# Rewrite the history by skipping given paths, ie deleting paths/files from the full history
# install git-filter-repo from https://github.com/newren/git-filter-repo/blob/main/INSTALL.md
git-filter-repo --invert-paths --path <path_1> --path <path_2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment