Do you know if there is a way to list the space usage of a git repository per branch ? (like df
or du
would)
By "the space usage" for a branch I mean "the space used by the commits which are not yet shared accross other branches of the repository".
This doesn’t have a proper answer. If you look at the commits contained only in a specific branch, you would get a list of blobs (basically file versions). Now you would have to check whether these blobs are part of any of the commits in the other branches. After doing that you will have a list of blobs that are only part of your branch.
Now you could sum up the size of these blobs to get a result – but that would probably be very wrong. Git compresses these blobs against each other, so the actual size of a blob depends on what other blobs are in your repo. You could remove 1000 blobs, 10MB each and only free 1kb of disk space.
Usually a big repo size is caused by single big files in the repo (if not, you are probably doing something wrong :). Info on how to find those can be found here: Find files in git repo over x megabytes, that don't exist in HEAD
In git 2.3.1 it supports --disk-usage
# reachable objects
git rev-list --disk-usage --objects --all
https://git-scm.com/docs/git-rev-list#_examples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With