Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find total size of uncommitted or untracked files in git

Tags:

git

linux

bash

I have a big horrible pile of code and I am setting it up in version control.

I would like a command I can run on Linux to give me the total size of the files that would be committed and pushed if I ran git add -A && git commit -am 'initial commit'

The total size is needed, also a break down by folder would be handy.

I will then use this to build up my ignores so that I can get the repo to a realistic size before I push it up

like image 333
edmondscommerce Avatar asked Feb 17 '14 15:02

edmondscommerce


1 Answers

I think I have answered my own question:

for f in `git status --porcelain | sed 's#^...##'`; do du -cs $f | head -n 1; done | sort -nr;  echo "TOTAL:"; du -cs .

However I'm open to any better ideas or useful tricks. My current output is 13GB :)


The above command is basically there, it gives me the total line by line from git status but doesn't give me the total sum. I'm currently getting the total of all files at the end which is not correct. I tried some use of bc but couldn't get it to work

like image 112
edmondscommerce Avatar answered Sep 23 '22 14:09

edmondscommerce