Skip to content

Instantly share code, notes, and snippets.

View ntanis-dev's full-sized avatar
🎯
Time is not enough.

Ntanis ntanis-dev

🎯
Time is not enough.
View GitHub Profile
@ntanis-dev
ntanis-dev / git_staged_files_size_check.sh
Last active April 28, 2025 21:33
Checks and displays the size of Git staged files. Tested in Ubuntu 22.04 LTS.
#!/bin/bash
num_files=$(git --no-pager diff --cached --name-only | wc -l)
if [ "$num_files" -eq 0 ]; then
echo -e "\033[91mERROR: You have no staged files.\033[0m"
exit 0
fi
total_size=$(git --no-pager diff --cached --name-only -z | xargs -0 du -b | awk '{total += $1} END {print total / 1024 / 1024}')