Skip to content

Instantly share code, notes, and snippets.

@ShogunPanda
Created March 5, 2014 21:14
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 ShogunPanda/9376739 to your computer and use it in GitHub Desktop.
Save ShogunPanda/9376739 to your computer and use it in GitHub Desktop.
Clean up large files from GIT repo.
#!/bin/bash
# Copyright (C) 2014 Shogun <shogun@cowtech.it>
# Run this script with a single argument which is the threshold size. Example: sh cleanup.sh 100k
# Find the files to remove
files=$(find * -type f -size +$1)
echo "Removing $files";
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch $files" --prune-empty --tag-name-filter cat -- --all
rm -rf .git/refs/original/ && git reflog expire --expire=now --all && git gc --aggressive --prune=now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment