-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove_git.sh
26 lines (22 loc) · 885 Bytes
/
remove_git.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
#!/bin/bash
# Author: giper
# Email: [email protected]
# Date:
# Description:
#
#
#
usage() {
echo $1
echo "Usage to_remove.sh [filetoremove]"
exit 1
}
if [ $# -ne 1 ]; then
usage "pls gives the file to remove"
fi
#Uncomment this for use with check_git.sh to remove max size objects
for i in $(cat $1 | sed 1,2d | awk '{print $4}'); do git filter-branch --tag-name-filter cat --index-filter "git rm -r --cached --ignore-unmatch $i" --prune-empty -f -- --all; done;
#Uncomment this for get the first value (to remove all the objects)
#for i in $(cat $1); do git filter-branch --tag-name-filter cat --index-filter "git rm -r --cached --ignore-unmatch $i" --prune-empty -f -- --all; done;
# Then reflog and clean cache
rm -rf .git/refs/original/ ; git reflog expire --expire=now --all ; git gc --prune=now; git gc --aggressive --prune=now