Last active
April 5, 2018 06:52
-
-
Save frode-carlsen/8a1524b6355fb432c9e6bec41fb773e8 to your computer and use it in GitHub Desktop.
Git memorable commands
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
# from https://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big | |
# Find large files and eradicate | |
git rev-list --all --objects | \ | |
sed -n $(git rev-list --objects --all | \ | |
cut -f1 -d' ' | \ | |
git cat-file --batch-check | \ | |
grep blob | \ | |
sort -n -k 3 | \ | |
tail -n40 | \ | |
while read hash type size; do | |
echo -n "-e s/$hash/$size/p "; | |
done) | \ | |
sort -n -k1 | |
# Remove file | |
git filter-branch -f --index-filter \ | |
'git rm --force --cached --ignore-unmatch video/parasite-intro.avi' \ | |
-- --all | |
# Clean up | |
rm -Rf .git/refs/original && \ | |
git reflog expire --expire=now --all && \ | |
git gc --aggressive && \ | |
git prune |
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
git reflog expire --all --expire=now | |
git gc --aggressive --prune=now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment