Git: Find duplicate blobs (files) in this tree

后端 未结 6 2100
长发绾君心
长发绾君心 2021-02-04 03:32

This is sort of a follow-up to this question.

If there are multiple blobs with the same contents, they are only stored once in the git repository because their SHA-1\'s

6条回答
  •  我寻月下人不归
    2021-02-04 04:34

    The scripting answers from your linked question pretty much apply here too.

    Try the following git command from the root of your git repository.

    git ls-tree -r HEAD
    

    This generates a recursive list of all 'blobs' in the current HEAD, including their path and their sha1 id.

    git doesn't maintain back links from a blob to tree so it would be a scripting task (perl, python?) to parse a git ls-tree -r output and create a summary report of all sha1s that appear more than once in the list.

提交回复
热议问题