DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Introducing 'Git Size' (Command and Visualization)

Introducing 'Git Size' (Command and Visualization)

Paul Hammant shares two commands for Git to help manage space on your hard drive.

Paul Hammant user avatar by
Paul Hammant
·
Aug. 17, 16 · DevOps Zone · Code Snippet
Like (1)
Save
Tweet
3.07K Views

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.

git size

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).

running it

$ 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

installation

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

visualizations

the site for visualizations: https://paul-hammant.github.io/git-size/ . it is the gh-pages branch of the git-size 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.

git slim

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).

installation

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:

unix command xargs 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 -a option but it’s not available installed on base os x.

i could have installed gnu’s xargs like so brew install findutils , but it would be gxargs instead of xargs and though still possible, it would be harder to keep git-size linux compatible.

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).

lastly, i really wanted to do a treemap , but nothing in javascript/svg was quite as pretty as the treemap of the fabled disk inventory x . so sunburst it was.

Git Visualization (graphics) Command (computing)

Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Leverage Speech-to-Text With Node.js
  • Fun With Modules
  • Back to Basics: Accessing Kubernetes Pods
  • Selenium vs Cypress: Does Cypress Replace Selenium?

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo