#!/bin/bash # BEVFusion项目Git仓库初始化脚本 # 在Docker容器内创建本地Git仓库 # 时间: 2025-11-14 set -e echo "🎯 开始初始化BEVFusion项目Git仓库" echo "📅 时间: $(date)" echo "📍 位置: Docker容器内" echo PROJECT_ROOT="/workspace/bevfusion" BACKUP_TIMESTAMP=$(date +%Y%m%d_%H%M%S) # 颜色输出 RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' print_status() { echo -e "${GREEN}✅ $1${NC}" } print_info() { echo -e "${BLUE}ℹ️ $1${NC}" } print_warning() { echo -e "${YELLOW}⚠️ $1${NC}" } # 检查是否已经是Git仓库 if [ -d "${PROJECT_ROOT}/.git" ]; then print_warning "Git仓库已存在,检查状态..." cd "${PROJECT_ROOT}" git status --short echo read -p "是否要重新初始化仓库? (y/N): " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "退出初始化" exit 0 fi # 备份现有仓库 echo "备份现有仓库..." mv .git .git_backup_${BACKUP_TIMESTAMP} print_status "原仓库已备份为 .git_backup_${BACKUP_TIMESTAMP}" fi cd "${PROJECT_ROOT}" # 步骤1: 初始化Git仓库 echo "📁 步骤1: 初始化Git仓库" git init print_status "Git仓库初始化完成" # 配置Git用户信息 git config user.name "BEVFusion Team" git config user.email "team@bevfusion.local" # 配置Git设置 git config core.filemode false git config core.autocrlf input git config core.safecrlf true print_status "Git配置完成" # 步骤2: 创建阶段性提交 echo echo "📝 步骤2: 创建有意义的提交历史" # 阶段1: 基础框架和核心依赖 print_info "提交阶段1: 基础框架和核心依赖" git add setup.py setup.cfg git add docker/ docker-compose.yml 2>/dev/null || true git add requirements.txt pyproject.toml 2>/dev/null || true if git diff --cached --quiet; then print_warning "阶段1没有新文件,跳过" else git commit -m "Initial setup: Project foundation and dependencies - Project setup files (setup.py, setup.cfg) - Docker configuration and compose files - Basic project structure and requirements Date: $(date) Phase: Project Initialization" print_status "阶段1提交完成" fi # 阶段2: 核心模型代码 print_info "提交阶段2: 核心模型代码" git add mmdet3d/ git add configs/ git add tools/train.py tools/test.py if git diff --cached --quiet; then print_warning "阶段2没有新文件,跳过" else git commit -m "Core model implementation: BEVFusion framework - Complete mmdet3d framework integration - BEVFusion model architecture (bevfusion.py) - Configuration files for Phase 4A and 4B - Training and testing tools Key Components: - Task-specific GCA module (gca.py) - RMT-PPAD integration (rmtppad_integration.py) - Enhanced transformer segmentation head Date: $(date) Phase: Core Implementation" print_status "阶段2提交完成" fi # 阶段3: 项目脚本和工具 print_info "提交阶段3: 项目脚本和工具" git add scripts/ 2>/dev/null || true git add *.sh git add tools/ --ignore-removal git add test_*.py debug_*.py monitor_*.py 2>/dev/null || true if git diff --cached --quiet; then print_warning "阶段3没有新文件,跳过" else git commit -m "Scripts and tools: Automation and utilities - Training startup scripts (Phase 4A, 4B) - Monitoring and debugging tools - Testing and validation scripts - Project automation utilities Key Scripts: - START_PHASE4B_RMTPPAD_SEGMENTATION.sh - START_PHASE4A_TASK_GCA.sh - Training monitoring scripts - Configuration validation tools Date: $(date) Phase: Tools and Automation" print_status "阶段3提交完成" fi # 阶段4: 分析文档和配置 print_info "提交阶段4: 分析文档和配置" git add *.md git add analysis_results/ 2>/dev/null || true git add eval_results/ 2>/dev/null || true if git diff --cached --quiet; then print_warning "阶段4没有新文件,跳过" else git commit -m "Documentation and analysis: Technical reports - Comprehensive project documentation - Architecture analysis reports - Performance evaluation results - Technical decision explanations Key Documents: - BEVFUSION_PROJECT_MASTER_PLAN.md - PHASE4B_NETWORK_ARCHITECTURE_ANALYSIS.md - RMT_PPAD_VS_BEVFUSION_HEAD_ANALYSIS.md - Training logs and evaluation reports Date: $(date) Phase: Documentation" print_status "阶段4提交完成" fi # 阶段5: 训练日志和数据 print_info "提交阶段5: 训练日志和数据 (可选)" # 注意: 日志文件可能很大,这里只添加关键的配置和结果 git add runs/phase4b_rmtppad_segmentation/train.log 2>/dev/null || true git add runs/run-*/train.log 2>/dev/null || true git add eval_results/ 2>/dev/null || true if git diff --cached --quiet; then print_warning "阶段5没有新文件,跳过" else git commit -m "Training logs and results: Experiment history - Training logs from Phase 4A and 4B - Evaluation results and metrics - Model checkpoints information - Performance tracking data Note: Large log files may be tracked separately Current training status: Epoch 2/10, 13.3% complete Date: $(date) Phase: Training History" print_status "阶段5提交完成" fi # 步骤3: 添加剩余文件 echo echo "📦 步骤3: 添加剩余文件" git add . --ignore-removal if git diff --cached --quiet; then print_info "没有剩余文件需要添加" else git commit -m "Final commit: Complete codebase snapshot - All remaining project files - Configuration files and assets - Miscellaneous project resources This commit represents the complete state of BEVFusion Phase 4B RMT-PPAD integration as of $(date) Training Status: Epoch 2/10 (13.3% complete) Segmentation Dice: 0.9594 Detection IoU: 0.5742 Date: $(date) Phase: Complete Snapshot" print_status "最终提交完成" fi # 步骤4: 创建分支结构 echo echo "🌿 步骤4: 创建分支管理结构" # 创建开发分支 git checkout -b development print_status "development分支创建" # 创建特性分支 git checkout -b feature/rmt-ppad-integration print_info "feature/rmt-ppad-integration分支创建" git checkout -b feature/task-specific-gca print_info "feature/task-specific-gca分支创建" # 回到主分支 git checkout master print_status "分支结构创建完成" # 步骤5: 创建备份bundle echo echo "📦 步骤5: 创建Git bundle备份" BUNDLE_NAME="bevfusion_backup_${BACKUP_TIMESTAMP}.bundle" git bundle create "${BUNDLE_NAME}" --all print_status "Git bundle创建完成: ${BUNDLE_NAME}" # 验证bundle print_info "验证bundle..." git bundle verify "${BUNDLE_NAME}" > /dev/null 2>&1 if [ $? -eq 0 ]; then print_status "Bundle验证通过" else print_warning "Bundle验证失败" fi # 步骤6: 显示仓库状态 echo echo "📊 步骤6: 显示仓库状态" echo "Git仓库状态:" git status --short echo echo "提交历史:" git log --oneline -10 echo echo "分支列表:" git branch -a echo echo "仓库统计:" echo "- 提交数量: $(git rev-list --count HEAD)" echo "- 文件数量: $(git ls-files | wc -l)" echo "- 仓库大小: $(du -sh .git | cut -f1)" echo "- Bundle大小: $(du -sh ${BUNDLE_NAME} | cut -f1)" # 步骤7: 创建使用指南 echo echo "📖 步骤7: 创建Git使用指南" cat > GIT_USAGE_GUIDE.md << GUIDE_EOF # BEVFusion Git仓库使用指南 ## 📋 仓库概览 BEVFusion项目的完整Git仓库,包括: - ✅ 核心模型代码 (mmdet3d框架) - ✅ 配置文件 (Phase 4A/4B) - ✅ 训练和测试工具 - ✅ 项目脚本和自动化工具 - ✅ 技术文档和分析报告 - ✅ 训练日志和结果 ## 🌿 分支结构 \`\`\` master # 主分支,稳定版本 ├── development # 开发分支,新功能开发 ├── feature/rmt-ppad-integration # RMT-PPAD集成特性 └── feature/task-specific-gca # Task-specific GCA特性 \`\`\` ## 🚀 基本操作 ### 查看状态 \`\`\`bash git status # 查看工作区状态 git log --oneline # 查看提交历史 git branch -a # 查看所有分支 \`\`\` ### 分支操作 \`\`\`bash git checkout development # 切换到开发分支 git checkout -b feature/new-feature # 创建新特性分支 git merge feature/some-feature # 合并分支 \`\`\` ### 代码管理 \`\`\`bash git add . # 添加所有更改 git commit -m "描述更改" # 提交更改 git push origin current-branch # 推送到远程 \`\`\` ## 📦 Bundle备份 仓库已创建备份文件: \`${BUNDLE_NAME}\` ### 从Bundle恢复仓库 \`\`\`bash # 方法1: 克隆bundle git clone ${BUNDLE_NAME} bevfusion_restored # 方法2: 从bundle创建裸仓库 git bundle unbundle ${BUNDLE_NAME} \`\`\` ## 🔄 定期维护 ### 创建新备份 \`\`\`bash git bundle create bevfusion_$(date +%Y%m%d).bundle --all \`\`\` ### 清理仓库 \`\`\`bash git gc # 垃圾回收 git prune # 清理无用对象 \`\`\` ## 📊 当前项目状态 - **训练进度**: Epoch 2/10 (13.3%完成) - **分割性能**: Dice系数 0.9594 - **检测性能**: IoU 0.5742 - **技术亮点**: RMT-PPAD Transformer集成 ## 📞 技术支持 如有Git相关问题,请参考: - \`git help \` - 查看命令帮助 - [Git官方文档](https://git-scm.com/doc) --- *仓库初始化时间: $(date)* *维护者: BEVFusion Team* GUIDE_EOF print_status "使用指南创建完成" # 最终总结 echo echo "🎉 Git仓库初始化完成!" echo echo "📊 仓库信息:" echo "- 位置: ${PROJECT_ROOT}" echo "- 分支: $(git branch --show-current)" echo "- 提交: $(git rev-parse --short HEAD)" echo "- Bundle: ${BUNDLE_NAME}" echo echo "📖 使用指南: GIT_USAGE_GUIDE.md" echo echo "🚀 下一步操作建议:" echo "1. 查看仓库状态: git status" echo "2. 浏览历史: git log --oneline" echo "3. 切换分支: git checkout development" echo "4. 备份bundle: 复制 ${BUNDLE_NAME} 到安全位置" echo echo "✅ BEVFusion项目代码已成功版本化管理!"