forked from Multibit-Legacy/multibit-hd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
git-purge.sh
executable file
·33 lines (25 loc) · 1.07 KB
/
git-purge.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
32
33
#!/bin/bash
echo "Removing history for *.war, *.jar, *.class files"
echo "Starting size"
git count-objects -v
echo "Removing history for *.war, *.jar, *.class files"
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.war' --prune-empty --tag-name-filter cat -- --all
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.jar' --prune-empty --tag-name-filter cat -- --all
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.class' --prune-empty --tag-name-filter cat -- --all
echo "Purging refs and garbage collection"
# Purge the backups
rm -Rf .git/refs/original
# Force reflog to expire now (not in the default 30 days)
git reflog expire --expire=now --all
# Prune
git gc --prune=now
# Aggressive garbage collection
git gc --aggressive --prune=now
echo
echo "Ending size (size-pack shows new size in Kb)"
git count-objects -v
# Can't do this in the script - it needs a human to be sure
echo
echo "Now use this command to force the changes into your remote repo (origin)"
echo
echo git push --all origin --force