tj.git-extras/bin/git-obliterate
oikarinen e691826b4b
Some checks failed
ci / lint (push) Has been cancelled
ci / typo (push) Has been cancelled
ci / test (push) Has been cancelled
ci / build (macos-latest) (push) Has been cancelled
ci / build (ubuntu-latest) (push) Has been cancelled
Fix all ShellCheck errors and add to CI (#1179)
2024-12-20 23:16:39 -08:00

24 lines
687 B
Bash
Executable file

#!/usr/bin/env bash
file=""
range=""
for i in "$@"
do
# use '--' to separate file list and rev-list arguments
test "$i" == '--' && shift && break
file="$file"' '"$i"
shift
done
test -n "$*" && range=("$@")
test -z "$file" && echo "file required." 1>&2 && exit 1
if [ -z "${range[*]}" ]
then
git filter-branch -f --index-filter "git rm -r --cached ""$file"" --ignore-unmatch" \
--prune-empty --tag-name-filter cat -- --all
else
# $range is an array so that we can forward multiple rev-list arguments
git filter-branch -f --index-filter "git rm -r --cached ""$file"" --ignore-unmatch" \
--prune-empty --tag-name-filter cat -- "${range[@]}"
fi