-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-flush
More file actions
executable file
·27 lines (22 loc) · 778 Bytes
/
git-flush
File metadata and controls
executable file
·27 lines (22 loc) · 778 Bytes
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
#!/usr/bin/env bash
#
# Original source: https://github.com/jwiegley/git-scripts/blob/master/git-flush
#
# The job of git-flush is to recompactify your repository to be as small
# as possible, by dropping all reflogs, stashes, and other cruft that may
# be bloating your pack files.
/bin/rm -fr .git/refs/original
/bin/rm -fr .git/refs/snapshots
if [ -f .git/info/refs ]; then
perl -i -ne 'print unless /refs\/original/;' .git/info/refs
perl -i -ne 'print unless /refs\/snapshots/;' .git/info/refs
fi
if [ -f .git/packed-refs ]; then
perl -i -ne 'print unless /refs\/original/;' .git/packed-refs
perl -i -ne 'print unless /refs\/snapshots/;' .git/packed-refs
fi
git reflog expire --expire=0 --all
if [ "$1" = "-f" ]; then
git stash clear
fi
git maxpack