Git精简
git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '$2 > 1048576' | sort -rnk2 | head
# 按照尺寸排序
git rev-list --objects --all | \
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | \
awk '$1=="blob" && $3>1048576 {print $3/1024/1024"MB", $2, $4}' | \
sort -rn | head -10
git rev-list --objects --all | \
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | \
awk '$1=="blob" && $3>1048576 {print $3/1024/1024"MB", $2, $4}' | \
sort -rn | head -10
# ✅ 正确的:比较第 3 列(文件大小),按第 3 列排序
git rev-list --objects --all | \
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | \
awk '$3 > 1048576' | \
sort -rnk3 | \
head
# 大于500k的文件
git rev-list --objects --all | \
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | \
awk '$3 > 504857' | \
sort -rnk3 | \
head
然后
# 本地初始化git
git init
# 添加远程源
gra origin git@github.com:lornally/keydog.git
# 强行推上去
gpsup