Newer
Older
JenkinsConfig / purge.sh
@Jenkins Jenkins on 3 Jan 2021 692 bytes daily backup
#!/bin/bash

if [ "$#" != "1" ]
then
  echo "usage:  $0 FILE"
  exit
fi

echo "Are you sure you want to delete $1?"
echo "This will permanently delete and remove all history of the file from git."
echo "Type 'YES' to proceed."

read LINE
if [ "$LINE" != "YES" ]
then
  echo "bailing out"
  exit
fi

echo "purging $1"

export FILE=$1
FILE=$1
git filter-branch -f \
    --prune-empty \
    --tag-name-filter cat \
    --tree-filter 'rm -f $FILE' \
    $(git log --follow --find-renames=40% --diff-filter=A --format=%H -- $FILE)~..HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all && git gc --prune=now --aggressive