Core Instructions
Step 1: Detect file changes
# 检查 Git 状态
git status
# 查看变更文件
git diff --name-only
Step 2: Add files
# 添加所有变更
git add .
Or add specified files
git add
### 第三步:生成提交信息
根据变更内容自动生成提交信息:
```bash
# 提交信息格式
<type>: <description>
# 类型说明
feat: 新功能
fix: 修复 bug
docs: 文档更新
style: 代码格式
refactor: 重构
test: 测试
chore: 构建/工具
Step 4: Commit and push
# 提交
git commit -m "提交信息"
# 推送
git push
Examples
Example 1: Automatically commit after analysis is complete
Trigger: Analysis task completed
Actions:
- Detect newly generated files
- Add to Git
- Generate commit message
- Commit and push
Commit message example:
feat: 完成股票分析
- 分析 000657 中钨高新
- 生成三高股票筛选报告
- 保存到 Stock-Analysis 仓库
Example 2: Multi-repository management
Trigger: Need to commit to multiple repositories
Actions:
- Identify the repository the files belong to
- Commit to the corresponding repositories separately
- Push separately
Repository examples:
- Jarvis: memory, configuration
- Stock-Analysis: stock analysis code
- Amazon-Analyzer: Amazon operations tools
Troubleshooting
Error 1: Git not configured
Error message: "Please tell me who you are"
Solution:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Error 2: Push failed
Error message: "Authentication failed"
Solution:
- Check Git credentials
- Use a Token instead of a password
- Configure SSH Key
Error 3: Conflict
Error message: "CONFLICT (content)"
Solution:
- View conflicting files
- Resolve conflicts manually
- Mark as resolved
git add <resolved_file> - Complete the commit
git commit
Best Practices
Commit frequency
- Small changes: commit at any time
- Large features: commit after the feature is complete
- End of each day: commit the day's work
Commit messages
- Clear and concise
- Use the present tense
- Capitalize the first letter
- No more than 50 characters
Branch management
- main/master: main branch
- feature/*: feature branch
- fix/*: fix branch
- docs/*: documentation branch