4 # Author: David Underhill
5 # Script to permanently delete files/folders from your git repository. To use
6 # it, cd to your repository's root and then run the script with a list of paths
7 # you want to delete, e.g., git-delete-history path1 path2
13 # make sure we're at the root of git repo
14 if [ ! -d .git ]; then
15 echo "Error: must run this script from the root of a git repository"
19 # remove all paths passed as arguments from the history of the repo
21 git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch $files" HEAD
23 # remove the temporary history git-filter-branch otherwise leaves behind for a long time
24 rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune