mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
24 lines
673 B
Bash
Executable file
24 lines
673 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
file=""
|
|
range=""
|
|
for i in "$@"
|
|
do
|
|
# use '--' to seperate 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
|
|
# don't quote $range 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
|