Skip to content

Commit a1db097

Browse files
peffgitster
authored andcommitted
docs/rev-list: add some examples of --disk-usage
It's not immediately obvious why --disk-usage might be a useful thing. These examples show off a few of the real-world cases I've used it for. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 669b458 commit a1db097

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Documentation/git-rev-list.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,47 @@ git rev-list [email protected] --since=1.year.ago --all
8383
git rev-list --objects HEAD
8484
----------
8585

86+
* Compare the disk size of all reachable objects, versus those
87+
reachable from reflogs, versus the total packed size. This can tell
88+
you whether running `git repack -ad` might reduce the repository size
89+
(by dropping unreachable objects), and whether expiring reflogs might
90+
help.
91+
+
92+
----------
93+
# reachable objects
94+
git rev-list --disk-usage --objects --all
95+
# plus reflogs
96+
git rev-list --disk-usage --objects --all --reflog
97+
# total disk size used
98+
du -c .git/objects/pack/*.pack .git/objects/??/*
99+
# alternative to du: add up "size" and "size-pack" fields
100+
git count-objects -v
101+
----------
102+
103+
* Report the disk size of each branch, not including objects used by the
104+
current branch. This can find outliers that are contributing to a
105+
bloated repository size (e.g., because somebody accidentally committed
106+
large build artifacts).
107+
+
108+
----------
109+
git for-each-ref --format='%(refname)' |
110+
while read branch
111+
do
112+
size=$(git rev-list --disk-usage --objects HEAD..$branch)
113+
echo "$size $branch"
114+
done |
115+
sort -n
116+
----------
117+
118+
* Compare the on-disk size of branches in one group of refs, excluding
119+
another. If you co-mingle objects from multiple remotes in a single
120+
repository, this can show which remotes are contributing to the
121+
repository size (taking the size of `origin` as a baseline).
122+
+
123+
----------
124+
git rev-list --disk-usage --objects --remotes=$suspect --not --remotes=origin
125+
----------
126+
86127
GIT
87128
---
88129
Part of the linkgit:git[1] suite

0 commit comments

Comments
 (0)