Files
novalon-website/scripts/git-cleanup.sh
T
张翔 3ce31d3178
ci/woodpecker/push/woodpecker Pipeline failed
feat: 优化CI/CD流程 - 自定义工具镜像、修复TLS问题、添加镜像清理脚本
- 创建轻量级工具镜像(novalon/tools:1.0.0)避免重复安装工具
- 修复Docker TLS handshake timeout问题
- 更新CI配置使用registry.f.novalon.cn/novalon/tools:1.0.0
- 添加自动清理脚本用于磁盘和镜像管理
2026-03-31 17:27:43 +08:00

67 lines
2.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Git仓库清理脚本 - 清理历史大文件
# 作者:张翔
# 日期:2026-03-31
echo "🚀 开始执行Git仓库清理..."
# 备份当前分支
echo "📋 备份当前分支..."
git branch git-cleanup-backup 2>/dev/null || echo "⚠️ 备份分支已存在"
# 1. 清理dist.tar.gz文件(1GB大文件)
echo "🗑️ 清理dist.tar.gz文件..."
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch dist.tar.gz' --prune-empty HEAD
# 2. 清理package-lock.json大文件
echo "🗑️ 清理package-lock.json大文件..."
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch package-lock.json' --prune-empty HEAD
# 3. 清理.next目录
echo "🗑️ 清理.next目录..."
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch .next' --prune-empty HEAD
# 4. 清理e2e快照文件
echo "🗑️ 清理e2e快照文件..."
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch e2e/src/tests/visual' --prune-empty HEAD
# 5. 清理test-framework报告
echo "🗑️ 清理test-framework报告..."
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch test-framework' --prune-empty HEAD
# 6. 清理大字体文件
echo "🗑️ 清理大字体文件..."
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch public/fonts/AoyagiReisho.ttf' --prune-empty HEAD
# 7. 清理Git引用日志
echo "🧹 清理Git引用日志..."
git reflog expire --expire=now --all
# 8. 强制垃圾回收
echo "🗑️ 强制垃圾回收..."
git gc --prune=now --aggressive
# 9. 清理临时备份
echo "🗑️ 清理临时备份..."
rm -rf .git/refs/original/
rm -rf .git/logs/
# 10. 显示清理结果
echo ""
echo "📊 Git仓库清理完成!"
echo "📦 当前Git仓库大小:"
du -sh .git
echo ""
echo "✅ Git仓库清理完成!"
echo "💡 建议:"
echo " 1. 将清理后的仓库推送到远程:git push --force --all"
echo " 2. 更新远程origingit push --force --tags"
echo " 3. 在.gitignore中添加以下规则:"
echo " dist.tar.gz"
echo " package-lock.json"
echo " .next/"
echo " e2e/src/tests/visual/"
echo " test-framework/"
echo " public/fonts/*.ttf"