Try git ls-files | xargs du -hs --threshold=1M
.
We use the below command in our CI pipeline, it halts if it finds any big files in the git repo:
test $(git ls-files | xargs du -hs --threshold=1M 2>/dev/null | tee /dev/stderr | wc -l) -gt 0 && { echo; echo "Aborting due to big files in the git repository."; exit 1; } || true