Skip to content

Instantly share code, notes, and snippets.

@FabreFrederic
Last active September 6, 2016 14:41
Show Gist options
  • Save FabreFrederic/4e1f4d6b406bd71270adc0a02297450e to your computer and use it in GitHub Desktop.
Save FabreFrederic/4e1f4d6b406bd71270adc0a02297450e to your computer and use it in GitHub Desktop.
Delete the files from your history repository
#!/bin/sh
#
# This script uses bfg-repo-cleaner
# https://rtyley.github.io/bfg-repo-cleaner
#
# Delete the files from your history repository
# The deleted files are listed in the $folder/deletedList.txt file
# You must run the getLargestFilesListFromRepository.sh script file before
#
folder="./cleanedFiles"
# Your bfg-repo-cleaner path
# You have to use the full path, don't use ~
bfg="/home/fred/develop/application/bfg-repo-cleaner/bfg-1.12.12.jar"
if [ ! -e $folder ];
then
echo "Error : cleanedFiles folder not found"
echo "You must run the script to get the largest files list before"
exit 1
fi
# File lines number
fileLinesNumber=$(wc -l < "$folder/deletedList.txt")
while read line; do
path=$(echo $line | awk '{ print $3 }')
fileName=$(basename $path)
echo "****************************************************"
echo "Processing file : $fileName"
echo "Remaining files : $fileLinesNumber"
echo "****************************************************"
java -jar $bfg --delete-files $fileName
fileLinesNumber=$((fileLinesNumber - 1))
done < $folder/deletedList.txt
echo "****************************************************"
echo "****************************************************"
git reflog expire --expire=now --all && git gc --prune=now
# repository check up
echo "****************************************************"
echo "****************************************************"
git fsck --full
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment