Motivation: I spend a fair amount of time jumping through hoops to keep my git repository clean and small. This means avoiding binary files and images, preferring download/generate scripts over raw data, etc. It would be quite useful to me to have a tool that helps me figure out the actual impact that a commit will have before I apply it.
My question has two parts: Size and Integration.
Size: How can I determine the impact of a git commit before I commit it? I have found a number of solutions to the "size" problem that don't really answer my question.
- Solution 1 - The top answer doesn't provide actual commands or a script, and is focused on network bandwidth. The second solution doesn't work.
- Solution 2 - The script linked in the accepted answer just looks at new files. What if I alter an existing file?
- Solution 3 - The script doesn't work. For example, my most recent commit is 0 bytes using this script. That can't be true because I modified a file, so there is some record in my git history with non-zero size stating exactly how the file was altered.
What I would really like is a script that tells me the following: If my repository's size on the git server is
S1
before I add, commit, and push, andS2
after I add, commit, and push, how can I figure out the valueX = S2 - S1
prior to adding, committing, and pushing?Integration: How can I best integrate this size calculation into my standard git flow? Ideally I would like this commit size
X
to be displayed to me whenever I rungit status
. For example (see "Impact"):$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: Impact: 1234 bytes (use "git reset HEAD ..." to unstage)
new file: new_file_1.png new file: new_file_2.sh new file: new_file_3.cpp
I can see how this might not be possible without editing the binary - if that's the case, then just having a script to run manually would be fine.