Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
448 views
in Technique[技术] by (71.8m points)

linux - 在git中查找未提交或未跟踪的文件的总大小(Find total size of uncommitted or untracked files in git)

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'

(我想要一个可以在Linux上运行的命令,以提供如果我运行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

(然后,我将使用它来构建我的忽略项,以便在回购之前将回购交易回购到现实的规模)

  ask by edmondscommerce translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 :)

(我当前的输出是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.

(上面的命令基本上就在这里,它从git status逐行给出了总计,但没有给出总计。)

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

(我尝试了一些使用bc但无法正常工作)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...