I want to find the size of the current checked-out files in a folder/project, but ignore the git directory.
Something like:
du . --ignore '.git'
Is there a way to find the size of all the files ignoring what's in the .git folder? When I do this:
du . --exclude='.git'
du . --exclude='./.git' # or this
Either way, I get:
du: --exclude=./.git: No such file or directory
What do I do?
For whatever reason (likely the BSD history of the Mac's utilities), the macOS version of du does not include --exclude. However, at least as of 10.14.x, it does include the much-less-obviously-named -I option which ignores items that are in the "mask" that is provided--in this case "mask" is just another name for some form of regular expression which at least takes simple * and ? wildcards.
Running
du -I .git .
gives the size heirarchy, and
du -s -I .git .
gives the summary. In both cases, the .git directory is ignored.
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