'example of `git add --dry-run .` listing file sizes in descending order?

I have a wide range of patterns in .gitignore, but sometimes things slip through.

Can someone tell me how to either:

  1. do a dry run of git add ./git add --all but get some sanity check output alerting me if something really big accidentally showed up.
  2. recursively match the contents of .gitignore against the project folder and list the complement with file sizes in descending order


Solution 1:[1]

Another approach would be to:

  • git add .
  • git commit -m "new commit"
  • list files per size to see if anything is amiss. If so, reset to @~.

To list file size of the new commit:

git ls-tree --format="%(objectsize) %(objectname)" @|sort -n -r

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC