Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8044701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:18:28+00:00 2026-06-05T05:18:28+00:00

Is it possible to show the total file size difference between two commits? Something

  • 0

Is it possible to show the total file size difference between two commits? Something like:

$ git file-size-diff 7f3219 bad418 # I wish this worked :)
-1234 bytes

I’ve tried:

$ git diff --patch-with-stat

And that shows the file size difference for each binary file in the diff — but not for text files, and not the total file size difference.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:18:30+00:00Added an answer on June 5, 2026 at 5:18 am

    git cat-file -s will output the size in bytes of an object in git. git diff-tree can tell you the differences between one tree and another.

    Putting this together into a script called git-file-size-diff located somewhere on your PATH will give you the ability to call git file-size-diff <tree-ish> <tree-ish>. We can try something like the following:

    #!/bin/bash
    USAGE='[--cached] [<rev-list-options>...]
    
    Show file size changes between two commits or the index and a commit.'
    
    SUBDIRECTORY_OK=1
    . "$(git --exec-path)/git-sh-setup"
    args=$(git rev-parse --sq "$@")
    [ -n "$args" ] || usage
    cmd="diff-tree -r"
    [[ $args =~ "--cached" ]] && cmd="diff-index"
    eval "git $cmd $args" | {
      total=0
      while read A B C D M P
      do
        case $M in
          M) bytes=$(( $(git cat-file -s $D) - $(git cat-file -s $C) )) ;;
          A) bytes=$(git cat-file -s $D) ;;
          D) bytes=-$(git cat-file -s $C) ;;
          *)
            echo >&2 warning: unhandled mode $M in \"$A $B $C $D $M $P\"
            continue
            ;;
        esac
        total=$(( $total + $bytes ))
        printf '%d\t%s\n' $bytes "$P"
      done
      echo total $total
    }
    

    In use this looks like the following:

    $ git file-size-diff HEAD~850..HEAD~845
    -234   Documentation/RelNotes/1.7.7.txt
    112    Documentation/git.txt
    -4     GIT-VERSION-GEN
    43     builtin/grep.c
    42     diff-lib.c
    594    git-rebase--interactive.sh
    381    t/t3404-rebase-interactive.sh
    114    t/test-lib.sh
    743    tree-walk.c
    28     tree-walk.h
    67     unpack-trees.c
    28     unpack-trees.h
    total 1914
    

    By using git-rev-parse it should accept all the usual ways of specifying commit ranges.

    EDIT: updated to record the cumulative total. Note that bash runs the while read in a subshell, hence the additional curly braces to avoid losing the total when the subshell exits.

    EDIT: added support for comparing the index against another tree-ish by using a --cached argument to call git diff-index instead of git diff-tree. eg:

    $ git file-size-diff --cached master
    -570    Makefile
    -134    git-gui.sh
    -1  lib/browser.tcl
    931 lib/commit.tcl
    18  lib/index.tcl
    total 244
    

    EDIT: Mark script as capable of running in a subdirectory of a git repository.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to show the typical iPhone maps annotation/callout bubble (MKAnnotation), on something
Is it possible to show and hide divs like scrolling style with mousedown() from
Is it possible to show (pop-up) a message box with an input field in
Is it possible to show the date/time of viewing/printing of a PDF document? I
Is it possible to show line numbers in the Developer Center when editing xslt
Is it possible to show a tooltip without making a link? For example, I
Is it possible to show any part of image in img tag (with pixels)
Is it possible to show quick documentation about highlighted item on the intellisense menu
Is it possible to show the working copy when doing searches in TortoiseHG? I've
Is it possible to show a preference with the unit (while still only taking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.