Skip to content

Instantly share code, notes, and snippets.

@ahayes91
Created December 5, 2019 14:58
Show Gist options
  • Save ahayes91/454c0f84d0af377cd273cbc56ca0cf51 to your computer and use it in GitHub Desktop.
Save ahayes91/454c0f84d0af377cd273cbc56ca0cf51 to your computer and use it in GitHub Desktop.
#!/bin/bash
read -p "Before commencing the script to remove the files, have you made a backup of your repository? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
read -p "Have you created a mirror clone of your repository, and have you removed any references to the files from the .gitignore file in your repo, and pushed this change? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
read -p "Is this laptop connected to LAN, connected to power, and have you ensured that this laptop will not sleep by changing Energy Settings on Mac? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
date
echo "Filtering files from git history using BFG tool"
java -jar bfg.jar --delete-files "{<NAME_OF_FILE_1.extension>,<NAME_OF_FILE_2.extension>}" <REPO>.git
cd <REPO>.git
git reflog expire --expire=now --all && git gc --prune=now
git push
date
else
echo "Please update your Mac energy settings before commencing this job."
exit
fi
else
echo "Please remove references to your files from the .gitignore file in your repo before commencing this job."
exit
fi
else
echo "Please make a backup before commencing this job."
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment