Skip to content

Commit a2ac758

Browse files
committed
Add John Wiegley's git-flush script.
1 parent 8147fa1 commit a2ac758

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ git clone this repository, then add it to your `$PATH`. Nothing here actually re
9898
* git-delete-local-merged - [https://plus.google.com/115587336092124934674/posts/dXsagsvLakJ](https://plus.google.com/115587336092124934674/posts/dXsagsvLakJ)
9999
* git-divergence - Gary Bernhardt's [dotfiles](https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn)
100100
* git-find-dirty - Matthew McCullough's [scripts](https://github.com/matthewmccullough/scripts/) repository
101+
* git-flush - John Wiegley's [git-scripts](https://github.com/jwiegley/git-scripts)
101102
* git-grab - Ryan Tomayko's [dotfiles](https://github.com/rtomayko/dotfiles)
102103
* git-improved-merge - Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles)
103104
* git-incoming - Michael Markert's [dotfiles](https://github.com/cofi/dotfiles)

git-flush

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
#
3+
# Original source: https://github.com/jwiegley/git-scripts/blob/master/git-flush
4+
#
5+
# The job of git-flush is to recompactify your repository to be as small
6+
# as possible, by dropping all reflogs, stashes, and other cruft that may
7+
# be bloating your pack files.
8+
9+
/bin/rm -fr .git/refs/original
10+
/bin/rm -fr .git/refs/snapshots
11+
12+
if [ -f .git/info/refs ]; then
13+
perl -i -ne 'print unless /refs\/original/;' .git/info/refs
14+
perl -i -ne 'print unless /refs\/snapshots/;' .git/info/refs
15+
fi
16+
if [ -f .git/packed-refs ]; then
17+
perl -i -ne 'print unless /refs\/original/;' .git/packed-refs
18+
perl -i -ne 'print unless /refs\/snapshots/;' .git/packed-refs
19+
fi
20+
21+
git reflog expire --expire=0 --all
22+
23+
if [ "$1" = "-f" ]; then
24+
git stash clear
25+
fi
26+
27+
git maxpack

0 commit comments

Comments
 (0)