How can I clean my .git folder? Cleaned up my project directory, but .git is still massive

前端 未结 5 1486
滥情空心
滥情空心 2020-12-12 10:54

The .git/objects in my rails project directory is still massive, after deleting hundreds of Megabytes of accidentally generated garbage.

<
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 11:22

    If you still have a large repo after pruning and repacking (gc --aggressive --prune=tomorrow...) then you can simply go looking for the odd one out:

    git rev-list --objects --all |
        while read sha1 fname
        do 
            echo -e "$(git cat-file -s $sha1)\t$\t$fname"
        done | sort -n
    

    This will give you a sorted list of objects in ascending size. You could use git-filter-branch to remove the culprit from your repo.

    See "Removing Objects" in http://progit.org/book/ch9-7.html for guidance

提交回复
热议问题