If your du
has no --exclude
option, you have two easy ways you can deal with this. This first one assumes that there are no hard-links between files in .git
and files elsewhere in the tree, but that's usually true:
- run
du
to get the total usage
- run
du
on .git
itself to get the .git
usage
- subtract the second number from the first number
The second easy way is to install a version of du
that does have --exclude
.
There is a third way to handle this, which is also pretty easy but a little tricky: just move .git
out of the way:
mv .git ../save-git
du ...
mv ../save-git .git
If you use this method, make sure nothing is trying to do anything Git-like in between. Or, make .git
a symbolic link to ../save-git
, or (if your Git is new enough) a plain-text file containing a redirect. Both of those methods can mess with the total, but only by one disk-block worth of space (the symlink or plain-text direct takes a disk block, unless the OS / file-system uses in-inode symlinks and the symlink is short enough to fit in-inode).