-
Notifications
You must be signed in to change notification settings - Fork 8
/
purgefiles.sh
executable file
·31 lines (22 loc) · 1.09 KB
/
purgefiles.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# list all files in the repo:
#git rev-list --objects --all
# store files to be deleted in filestoremove.dat:
#git rev-list --objects --all | fgrep data/pulsefish | awk '{print $2}' > filestoremove.dat
# remove all references to the files from the active history of the repo:
for i in $(<filestoremove.dat); do
echo $i
git filter-branch --force --index-filter "git rm -r --cached --ignore-unmatch $i" --prune-empty --tag-name-filter cat -- --all
done
# force all references to the file to be expired and purged from the packfile:
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --aggressive --prune=now
# push:
git push origin --force --all
git push origin --force --tags
# then rebase all or remove and clone anew!
# for details see:
# https://help.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository
# https://stackoverflow.com/questions/11050265/remove-large-pack-file-created-by-git
# https://stackoverflow.com/questions/460331/git-finding-a-filename-from-a-sha1