Skip to content

Instantly share code, notes, and snippets.

@prashantdsala
Created September 4, 2023 11:08
Show Gist options
  • Save prashantdsala/775edd42f8c5b6336ac1b820d737c17d to your computer and use it in GitHub Desktop.
Save prashantdsala/775edd42f8c5b6336ac1b820d737c17d to your computer and use it in GitHub Desktop.
Reduce .git folder size
# To see the 10 biggest files, run this from the root directory:
$ git verify-pack -v .git/objects/pack/pack-7b03cc896f31b2441f3a791ef760bd28495697e6.idx \
| sort -k 3 -n \
| tail -10
# To see what each file is, run this:
$ git rev-list --objects --all | grep [first few chars of the sha1 from previous output]
# Rewrite all the commits:
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch "Folder Name/*"' -- --all
$ rm -Rf .git/refs/original
$ rm -Rf .git/logs/
$ git gc --aggressive --prune=now
Then verify:
$ git count-objects -v
Source: https://usunyu.com/note/2017/06/07/reduce-git-folder/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment