Closed apos closed 1 year ago
[2.] rewrote the script for use with git-filter-repo:
#!/bin/bash
set -o errexit
# Author: David Underhill
# Rewrote for usage with git filter repo
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
#
# retrieved from: http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
#
if [ $# -eq 0 ]; then
echo "You need to specify a list of paths you like to remove."
exit 1
fi
if [ which git-filter-repo ]
then
echo -n ""
else
echo "Please instlal git-filter-repo"
exit 1
fi
echo "Try creating a backup for safty (requires rsync - in any case!)"
if which rsync
then
myRepo="$(pwd)"
if [ -f git_backup_made_$(date +%F) ]
then
echo "There is already a backup of your git :-)"
echo "${myRepo}_backup_$(date +%F)"
else
rsync -av --delete "${myRepo}/." "${myRepo}_backup_$(date +%F)"
touch git_backup_made_$(date +%F)
fi
else
echo "rsync MUST be installed. You need a backup"
exit 1
fi
# make sure we're at the root of git repo
if [ ! -d .git ]; then
echo "Error: must run this script from the root of a git repository"
exit 1
fi
# remove all paths passed as arguments from the history of the repo
firs=$@
git filter-repo --path ${dirs} --invert-paths --force