Git - get all commits and blobs they created

后端 未结 6 1292
天涯浪人
天涯浪人 2020-12-05 03:07

Is there a git command that can output for every commit:

  1. id
  2. subject
  3. blobs it created with they path and size (like git ls-tree -l -r &l
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 03:58

    To get commits (all and output one line per commit):

    git rev-list --all --pretty=oneline
    

    Then split commits by space with limit of 2 and get every commit id and message

    To get blobs created by commit (recurse to subdirs, show merge commits, detect renames and copies, don't show commit id on first line):

    git diff-tree -r -c -M -C --no-commit-id 
    

    A bit of parsing of every line and excluding some of them — and we get list of new blobs and they path for commit

    Last is to get blob sizes:

    git cat-file --batch-check < 
    

    And another time a bit of parsing

提交回复
热议问题