git find fat commit

后端 未结 7 1514
借酒劲吻你
借酒劲吻你 2020-12-01 04:03

Is it possible to get info about how much space is wasted by changes in every commit — so I can find commits which added big files or a lot of files. This is all to try to r

相关标签:
7条回答
  • 2020-12-01 04:39

    Forgot to reply, my answer is:

    git rev-list --all --pretty=format:'%H%n%an%n%s'    # get all commits
    git diff-tree -r -c -M -C --no-commit-id #{sha}     # get new blobs for each commit
    git cat-file --batch-check << blob ids              # get size of each blob
    
    0 讨论(0)
  • 2020-12-01 04:39

    git fat find N where N is in bytes will return all the files in the whole history which are larger than N bytes.

    You can find out more about git-fat here: https://github.com/cyaninc/git-fat

    0 讨论(0)
  • 2020-12-01 04:40
    #!/bin/bash
    COMMITSHA=$1
    
    CURRENTSIZE=$(git ls-tree -lrt $COMMITSHA | grep blob | sed -E "s/.{53} *([0-9]*).*/\1/g" | paste -sd+ - | bc)
    PREVSIZE=$(git ls-tree -lrt $COMMITSHA^ | grep blob | sed -E "s/.{53} *([0-9]*).*/\1/g" | paste -sd+ - | bc)
    echo "$CURRENTSIZE - $PREVSIZE" | bc
    
    0 讨论(0)
  • 2020-12-01 04:42

    You could do this:

    git ls-tree -r -t -l --full-name HEAD | sort -n -k 4
    

    This will show the largest files at the bottom (fourth column is the file (blob) size.

    If you need to look at different branches you'll want to change HEAD to those branch names. Or, put this in a loop over the branches, tags, or revs you are interested in.

    0 讨论(0)
  • 2020-12-01 04:45

    Personally, I found this answer to be most helpful when trying to find large files in the history of a git repo: Find files in git repo over x megabytes, that don't exist in HEAD

    0 讨论(0)
  • 2020-12-01 04:54

    git cat-file -s <object> where <object> can refer to a commit, blob, tree, or tag.

    0 讨论(0)
提交回复
热议问题