美文网首页
关于如何查找历史中的大型文件那些事

关于如何查找历史中的大型文件那些事

作者: Wavky | 来源:发表于2018-09-22 12:31 被阅读0次
  1. 检查Repo体积是否有异常
du -sh
  1. 运行脚本,在Repo历史提交中搜索大型文件(按体积倒序排列前10位,单位为kB,SHA1为blob编码)

git_find_big.sh

#!/bin/bash
#set -x 

# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs

# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
IFS=$'\n';

# list all objects including their size, sort by size, take top 10
objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head`

echo "All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file."

output="size,pack,SHA,location"
for y in $objects
do
    # extract the size in bytes
    size=$((`echo $y | cut -f 5 -d ' '`/1024))
    # extract the compressed size in bytes
    compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
    # extract the SHA
    sha=`echo $y | cut -f 1 -d ' '`
    # find the objects location in the repository tree
    other=`git rev-list --all --objects | grep $sha`
    #lineBreak=`echo -e "\n"`
    output="${output}\n${size},${compressedSize},${other}"
done

echo -e $output | column -t -s ', '
  1. 根据给定的文件blob’s SHA1编码定位提交历史(SHA1以第一个参数形式传入调用)

git_find_blob_commit.sh

#!/bin/sh
obj_name="$1"
shift
git log "$@" --pretty=format:'%T %h %s' \
| while read tree commit subject ; do
    if git ls-tree -r $tree | grep -q "$obj_name" ; then
        echo $commit "$subject"
    fi
done

git - Which commit has this blob? - Stack Overflow

从所有历史中删除特定文件

使用filter-branch命令,参考 Gitリポジトリをメンテナンスして軽量化する

相关文章

  • 关于如何查找历史中的大型文件那些事

    检查Repo体积是否有异常 运行脚本,在Repo历史提交中搜索大型文件(按体积倒序排列前10位,单位为kB,SHA...

  • day14 - find查找

    为什么要有文件查找 2.windows如何实现文件查找? 3.linux如何实现文件查找? 4.find命令查找语...

  • linux使用记录(待续)

    命令 查看当前路径命令: 列出当前目录文件 清空日志文件: 查看命令行历史: 查找大文件夹: 查找大文件: 查找进...

  • Linux文件查找操作

    简介 介绍在Linux系统中如何查找、定位文件 文件搜索定位 grep find whereis which PATH

  • Pycharm Shortcut

    1. 快速查找文件 开发大型项目时,文件数量非常庞大,有时要在不同的文件之间来回切换,如果还是从左侧工程目录中按层...

  • 查找历史版本的文件

    1. 可能没有保存的文件, 找不到了, 可能是某个文件之前的历史版本 方法: C:/Documents and S...

  • 测试

    lunix指令,如给定文件名,如何查找、如何查找包含某个内容的文件,是否使用awk,sed SQL连接查询 编程:...

  • linux命令记录

    查找文件 find / -name fileName 在根目录中查找文件fileName 在文件中检索字符 ...

  • Linux中常用的查找命令

    linux 中常用的查找文件和文件中字符串的操作: 在某个路径下查找文件 例如在 /etc 中查找 "*.log"...

  • 关于印度历史的那些事

    作为中国的老邻居,印度一直晃荡在国人的视野里。尤其是疫情之后,印度的一系列神操作,更成为众多网友的玩梗的素材,...

网友评论

      本文标题:关于如何查找历史中的大型文件那些事

      本文链接:https://www.haomeiwen.com/subject/mcztoftx.html