Introducing 'Git Size' (Command and Visualization)
Paul Hammant shares two commands for Git to help manage space on your hard drive.
Join the DZone community and get the full member experience.Join For Free
i’m trying to slim things down — it’s easy to fill a 256gb hard drive on a mac when you like poking around other people’s source code on github. and, perhaps, 100 of your own repos.
i wrote two commands for git in bash to supplement git.
as run on my mac (after i zapped 50gb of git repos):
the ‘git size’ sub-command: https://github.com/paul-hammant/git-size (~patches~ prs welome).
$ git size jbehave/jbehave-core/ jbehave/jbehave-core: git size: .git folder: 31m checkout: 11.6m ignored: 8.1m total: 50m
or, recursive and csv:
$ git size --csv --csv-headers --recursive . directory_name,dot_git_folder_size,checkout_size,ignored_size,total_size "jbehave/jbehave-core",31320,11924,8344,51588 "jbehave/jbehave-tutorial",728,220,0,948 "jbehave/jbehave-web",1772,1396,920,4088 "maven-hpi-plugin",1784,620,1328,3732 "xunit-plugin",1416,3588,14928,19932
how to install that on a mac with homebrew (so you can just do ‘git size’ like other git commands): github.com/paul-hammant/homebrew-tap#git-size
the site for visualizations:
. it is the gh-pages branch of the
repo, of course.
that pic is the example linked to from the homepage, above. the link itself (so you can see):
https://paul-hammant.github.io/git-size/total.html#impizwhhdmuvamjlagf2zs1jb3jliiwzmtmymcwx mtkyncw4mzq0lduxntg4cijqymvoyxzll2pizwhhdmutdhv0b3jpywwildcyocwymjasmcw5ndgkimpizwhhdmuvamjl agf2zs13zwiilde3nzismtm5niw5mjasnda4oaoibwf2zw4tahbplxbsdwdpbiismtc4ncw2mjasmtmyocwznzmycij4 dw5pdc1wbhvnaw4ilde0mtysmzu4ocwxndkyocwxotkzmgo=
yes, that’s a long url. it’s ok the browser can handle it. note that the stuff to the right of the # will not be sent to the github web-server hosting the files. the stuff to the right of the # is a base64 encoded form of the csv above, or course.
this might be buggy, but it works for me - a way to reduce the depth of a clone in-situ.
the ‘git slim’ sub-command: https://github.com/paul-hammant/git-slim
$ cd jbehave/jbehave-core $ git slim size of .git folder before: 31m, best case size after: 3.4m (approx).
how to install that on a mac (so you can just do ‘git slim’ as any git command): github.com/paul-hammant/homebrew-tap#git-slim
thoughts after making these
bash is quite picky generally, but there’s a particular snafu that bogged me down quite a bit:
can blow up
when using it to calculate the size of a list of files. i had to drop it, and iterate over files adding up kb sizes. there’s a
option but it’s not available installed on base os x.
i could have installed gnu’s
brew install findutils
, but it would be
instead of xargs and though still possible, it would be harder to keep
the d3-using sunburst chart really has to stay online - it is too much for a simple bash-script to handle. it is also a fork of something pre-existing , and i had trouble making it into a single page that could switch between the four size types passed in via csv (the four radio buttons at the top).
Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.