Skip to content

Instantly share code, notes, and snippets.

@frode-carlsen
Last active April 5, 2018 06:52
Show Gist options
  • Save frode-carlsen/8a1524b6355fb432c9e6bec41fb773e8 to your computer and use it in GitHub Desktop.
Save frode-carlsen/8a1524b6355fb432c9e6bec41fb773e8 to your computer and use it in GitHub Desktop.
Git memorable commands
# 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
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