How to see the file size history of a single file in a git repository?

前端 未结 8 1662
遇见更好的自我
遇见更好的自我 2020-12-03 06:52

Is there anyway to see how a file\'s size has changed through time in a git repository? I want to see how my main.js file (which is the combination of several files and mini

8条回答
  •  不思量自难忘°
    2020-12-03 07:26

    Create a file called .gitattributes and add the following line:

    main.js -diff
    

    This turns off line-based diffs for main.js. Now run the following command:

    git log --stat main.js
    

    The log will include lines like

    main.js | Bin 4316 -> 4360 bytes
    

    After you're done, you should probably delete .gitattributes. I don't know what other changes in git's behavior may be caused by the -diff attribute.

    Tested with git versions 1.7.12.4 and 1.7.9.5.

    Source: ewall's answer and https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html#_marking_files_as_binary

提交回复
热议问题