Last active
August 28, 2017 10:41
-
-
Save ashugupt/1d46fac48446f7c0408f9c8deab22c84 to your computer and use it in GitHub Desktop.
Cleanup a git repository of unwanted files/history
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all large blobs in a git repository sorted by blob size in descending order. | |
git rev-list --objects master | git cat-file --batch-check='%(objectsize) %(objecttype) %(objectname) %(rest)' | sort -k1,1 -rn > ~/Desktop/abc.txt | |
# Rewrite history removing history of a file | |
git filter-branch --force --index-filter \ | |
'git rm --cached --ignore-unmatch <path/to/unwanted/file>' \ | |
--prune-empty --tag-name-filter cat -- --all | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment