SuperAPI AI Directory

git-workflow

Coding & development

View repository

Updated 10-15 07:58

About this skill

Git workflow skill

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:

  1. Detect newly generated files
  2. Add to Git
  3. Generate commit message
  4. Commit and push

Commit message example:

feat: 完成股票分析

- 分析 000657 中钨高新
- 生成三高股票筛选报告
- 保存到 Stock-Analysis 仓库

Example 2: Multi-repository management

Trigger: Need to commit to multiple repositories

Actions:

  1. Identify the repository the files belong to
  2. Commit to the corresponding repositories separately
  3. 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:

  1. Check Git credentials
  2. Use a Token instead of a password
  3. Configure SSH Key

Error 3: Conflict

Error message: "CONFLICT (content)"

Solution:

  1. View conflicting files
  2. Resolve conflicts manually
  3. Mark as resolved
    git add <resolved_file>
    
  4. 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