Files
erp-ass/docs/GIT_GUIDE.md
dazhuang acd73431ae feat: implement ERP AI Assistant Phase 1
Backend (FastAPI + SQLAlchemy + Claude API + RAG):
- Config management with Pydantic v2
- Database engine with connection pooling and SQL injection prevention
- AI engine with Claude API integration (support custom base URL)
- RAG engine with ChromaDB and sentence-transformers
- Requirement analysis service
- Config generation service
- Executor engine with SQL validation
- REST API endpoints: /analyze, /generate, /execute

Frontend (Vue 3 + Element Plus + Pinia):
- Complete 3-step workflow: analyze → generate → execute
- Step indicator with progress visualization
- Analysis result display with field table
- SQL preview with monospace font
- Execute confirmation dialog with safety warning
- Execution result display
- State management with Pinia
- API service integration

Security:
- SQL injection prevention with parameterized queries
- Dangerous SQL operation blocking
- Database password URL encoding
- Transaction auto-rollback
- Pydantic config validation

Features:
- Natural language requirement analysis
- Automated SQL configuration generation
- Safe execution with human review
- LAN access support
- Custom Claude API endpoint support

Documentation:
- README with quick start guide
- Quick start guide
- LAN access configuration
- Dependency fixes guide
- Claude API configuration
- Git operation guide
- Implementation report

Dependencies fixed:
- numpy<2.0.0 for chromadb compatibility
- sentence-transformers==2.7.0 for huggingface_hub compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 14:23:20 +00:00

4.5 KiB
Raw Permalink Blame History

Git 操作指南 - 撤回和重新添加文件

已完成的操作

1. 撤回暂存区

已执行 git reset 命令,清空了暂存区的所有文件。

📝 修改的 .gitignore

已在 .gitignore 中添加以下规则:

# Project specific - 忽略知识库文档
backend/knowledge_base/documents/*.docx
backend/knowledge_base/documents/*.xlsx
backend/knowledge_base/documents/*.pdf
backend/knowledge_base/documents/*.pptx
backend/knowledge_base/documents/*.vsdx
backend/knowledge_base/documents/*.xls

# Temporary files - 忽略临时文件
*.tmp
*.temp
*.bak
*.swp
*~

# Archives - 忽略压缩包
*.zip
*.tar.gz
*.rar
*.7z

🔍 下一步操作

1. 查看将要提交的文件

先查看哪些文件会被添加:

# 查看所有未跟踪的文件
git status

# 或者更详细地查看
git status --short

2. 重新添加文件

确认文件列表无误后:

# 方式 1: 添加所有文件(推荐)
git add .

# 方式 2: 逐个添加文件类型(更安全)
git add backend/app/
git add backend/tests/
git add backend/*.txt backend/*.ini
git add backend/.env.example
git add frontend/src/
git add frontend/*.json frontend/*.js frontend/*.html
git add *.md .gitignore

3. 检查暂存区

添加后再次检查:

# 查看暂存区状态
git status

# 查看暂存区的文件列表
git diff --cached --name-only

# 查看具体改动
git diff --cached

4. 提交

确认无误后提交:

git commit -m "feat: implement ERP AI Assistant Phase 1

- Backend: FastAPI + SQLAlchemy + Claude API + RAG
- Frontend: Vue 3 + Element Plus + Pinia
- Features: requirement analysis, config generation, safe execution
- Security: SQL injection prevention, parameterized queries
- Support: LAN access, custom API endpoint"

🎯 建议忽略的文件

如果发现还有其他不需要提交的文件,可以在 .gitignore 中添加:

常见需要忽略的文件类型

# 大文件
*.dmg
*.iso
*.img

# 编译产物
*.class
*.exe
*.dll
*.so
*.dylib

# 包文件
*.jar
*.war
*.ear

# 日志文件
logs/
*.log

# 数据文件
*.csv
*.dat
*.out

# 模型文件(如果很大的话)
*.model
*.pkl
*.h5
*.pt
*.pth

项目特定的忽略规则

# 知识库向量数据库(可能很大)
backend/knowledge_base/chroma_db/

# 用户上传的文档
backend/knowledge_base/documents/

# 测试覆盖率报告
htmlcov/
.coverage

# 本地配置
.env.local
.env.*.local

🔧 Git 常用命令

撤回操作

# 撤回所有已 add 的文件
git reset

# 撤回特定文件
git reset <file>

# 撤回最近一次 commit保留修改
git reset --soft HEAD~1

# 撤回最近一次 commit丢弃修改慎用
git reset --hard HEAD~1

查看状态

# 查看当前状态
git status

# 查看简洁状态
git status -s

# 查看分支信息
git branch -a

# 查看提交历史
git log --oneline --graph

删除已跟踪的文件

如果某个文件已经被 git 跟踪,想要从版本控制中移除:

# 从 Git 中移除但保留本地文件
git rm --cached <file>

# 从 Git 和本地都删除
git rm <file>

# 从 Git 中移除整个文件夹
git rm -r --cached <directory>

📋 快速检查清单

提交前检查:

  • 是否包含 .env 文件?(不应包含)
  • 是否包含 venv/node_modules/?(不应包含)
  • 是否包含大文件?(不应包含)
  • 是否包含临时文件?(不应包含)
  • 是否包含日志文件?(不应包含)
  • 是否包含个人配置?(不应包含)

🚨 常见问题

问题 1: 文件已经在 .gitignore 中,但仍然被跟踪

原因: 文件在添加 .gitignore 规则之前就已经被 git 跟踪了

解决方案:

# 从 Git 中移除但保留本地文件
git rm --cached <file>

# 然后提交
git commit -m "chore: remove tracked file from version control"

问题 2: 添加了不该添加的文件

解决方案:

# 1. 撤回添加
git reset

# 2. 更新 .gitignore

# 3. 重新添加
git add .

问题 3: 如何只提交特定文件

解决方案:

# 只提交代码文件
git add *.py *.vue *.js

# 只提交特定目录
git add backend/app/ frontend/src/

# 交互式添加
git add -p

📚 相关资源


更新时间: 2026-03-21