git-log

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Log - Commit & Documentation

Git Log - 提交与文档管理

Generate structured commit messages and maintain comprehensive git log documentation for the VRP toolkit project.
为VRP工具包项目生成结构化的提交信息,并维护全面的Git日志文档。

When to Use

适用场景

Use this skill when:
  • Preparing to commit changes to the repository
  • Reviewing git history to understand recent changes
  • Maintaining the project's change documentation
  • Need quick reference for common git commands
  • Want to ensure consistent commit message formatting
在以下场景中使用本技能:
  • 准备向代码仓库提交变更时
  • 查看Git历史记录以了解近期变更时
  • 维护项目的变更文档时
  • 需要常用Git命令的快速参考时
  • 希望确保提交信息格式一致时

Core Workflow: Commit & Log

核心工作流:提交与日志

Step 1: Analyze Changes

步骤1:分析变更

Before committing, analyze the current changes:
bash
git status
git diff --staged  # If changes already staged
git diff           # If changes not staged
Key questions to answer:
  • What files were modified/added/deleted?
  • What is the nature of changes (feature, bug fix, docs, refactor)?
  • What scope is affected (e.g., architecture, setup, migration)?
提交前,先分析当前的变更:
bash
git status
git diff --staged  # 若变更已暂存
git diff           # 若变更未暂存
需要明确的关键问题:
  • 哪些文件被修改/添加/删除?
  • 变更的性质是什么(功能新增、Bug修复、文档更新、代码重构)?
  • 影响的范围是什么(例如:架构、配置、迁移)?

Step 2: Generate Commit Message

步骤2:生成提交信息

Based on the changes, generate a commit message following Conventional Commits format:
Format:
<type>(<scope>): <subject>
Common types for this project:
  • feat
    : New feature or functionality
  • fix
    : Bug fix
  • docs
    : Documentation changes
  • refactor
    : Code refactoring (no behavior change)
  • test
    : Adding or updating tests
  • chore
    : Maintenance tasks, dependency updates
  • style
    : Code style changes (formatting, etc.)
Common scopes for this project:
  • architecture
    : Changes to overall architecture
  • migration
    : File migrations from SDR_stochastic
  • setup
    : Project setup, installation, dependencies
  • alns
    : ALNS algorithm changes
  • pdptw
    : PDPTW problem definition
  • data
    : Data layer changes
  • visualization
    : Visualization tools
  • tutorials
    : Tutorial notebooks
Subject guidelines:
  • Use imperative mood: "add" not "added" or "adds"
  • First letter lowercase
  • No period at end
  • Keep under 50 characters if possible
Body (optional but recommended):
  • Explain what changed and why
  • Use bullet points for multiple changes
  • Reference issues or related work
Examples:
feat(architecture): implement unified Solver interface for problem-algorithm separation

- Create VRPProblem, VRPSolution, Solver abstract base classes
- Implement ALNSSolver adapter pattern
- Update quickstart tutorial to demonstrate new interface
chore: update migration progress (9/9 files)

- Update CLAUDE.md completed tasks section
- Add migration entry to MIGRATION_LOG.md
- Update progress statistics
根据变更内容,遵循Conventional Commits格式生成提交信息:
格式:
<type>(<scope>): <subject>
本项目常用类型:
  • feat
    : 新功能或功能增强
  • fix
    : Bug修复
  • docs
    : 文档变更
  • refactor
    : 代码重构(无行为变更)
  • test
    : 添加或更新测试
  • chore
    : 维护任务、依赖更新
  • style
    : 代码样式变更(格式化等)
本项目常用范围:
  • architecture
    : 整体架构变更
  • migration
    : 从SDR_stochastic迁移文件
  • setup
    : 项目配置、安装、依赖
  • alns
    : ALNS算法变更
  • pdptw
    : PDPTW问题定义
  • data
    : 数据层变更
  • visualization
    : 可视化工具
  • tutorials
    : 教程笔记本
主题编写指南:
  • 使用祈使语气:用"add"而非"added"或"adds"
  • 首字母小写
  • 结尾不加句号
  • 尽可能控制在50个字符以内
正文(可选但推荐):
  • 说明变更内容及原因
  • 多项变更使用项目符号列出
  • 关联相关问题或工作
示例:
feat(architecture): implement unified Solver interface for problem-algorithm separation

- Create VRPProblem, VRPSolution, Solver abstract base classes
- Implement ALNSSolver adapter pattern
- Update quickstart tutorial to demonstrate new interface
chore: update migration progress (9/9 files)

- Update CLAUDE.md completed tasks section
- Add migration entry to MIGRATION_LOG.md
- Update progress statistics

Step 3: Maintain Git Log Documentation

步骤3:维护Git日志文档

After committing, update the git log documentation file (
.claude/GIT_LOG.md
):
File structure:
markdown
undefined
提交完成后,更新Git日志文档文件(
.claude/GIT_LOG.md
):
文件结构:
markdown
undefined

Git Log - VRP Toolkit Project

Git Log - VRP Toolkit Project

Comprehensive record of all commits with detailed information.
Comprehensive record of all commits with detailed information.

Recent Commits (newest first)

Recent Commits (newest first)

2026-01-01 - feat(architecture): implement unified Solver interface

2026-01-01 - feat(architecture): implement unified Solver interface

Hash: 4569fa1 Author: [Author Name] Date: 2026-01-01 12:34:56
Changes:
  • Created base.py module with abstract base classes
  • Implemented adapter pattern for backward compatibility
  • Updated quickstart tutorial
Files modified:
  • vrp_toolkit/algorithms/base.py
  • vrp_toolkit/algorithms/alns/solver.py
  • tutorials/01_quickstart.ipynb

Hash: 4569fa1 Author: [Author Name] Date: 2026-01-01 12:34:56
Changes:
  • Created base.py module with abstract base classes
  • Implemented adapter pattern for backward compatibility
  • Updated quickstart tutorial
Files modified:
  • vrp_toolkit/algorithms/base.py
  • vrp_toolkit/algorithms/alns/solver.py
  • tutorials/01_quickstart.ipynb

2025-12-31 - chore: update migration progress (9/9)

2025-12-31 - chore: update migration progress (9/9)

Hash: 9590014 Author: [Author Name] Date: 2025-12-31 10:20:30
Changes:
  • Updated CLAUDE.md with completed migration status
  • Added final migration entry to MIGRATION_LOG.md
Files modified:
  • .claude/CLAUDE.md
  • .claude/MIGRATION_LOG.md

**Update process:**
1. Extract commit information: `git log -1 --pretty=format:"%H|%an|%ad|%s" --date=iso`
2. Get changed files: `git show --name-only --pretty=format:"" HEAD`
3. Format entry using template above
4. Add to top of "Recent Commits" section in `.claude/GIT_LOG.md`
5. Keep only last 20-30 commits in main section (archive older ones if needed)
Hash: 9590014 Author: [Author Name] Date: 2025-12-31 10:20:30
Changes:
  • Updated CLAUDE.md with completed migration status
  • Added final migration entry to MIGRATION_LOG.md
Files modified:
  • .claude/CLAUDE.md
  • .claude/MIGRATION_LOG.md

**更新流程:**
1. 提取提交信息:`git log -1 --pretty=format:"%H|%an|%ad|%s" --date=iso`
2. 获取变更文件:`git show --name-only --pretty=format:"" HEAD`
3. 使用上述模板格式化条目
4. 将条目添加到`.claude/GIT_LOG.md`的"Recent Commits"部分顶部
5. 主部分仅保留最近20-30条提交(必要时归档旧提交)

Step 4: Execute Commit

步骤4:执行提交

Provide the user with exact commands to execute:
bash
undefined
为用户提供可直接执行的命令:
bash
undefined

Stage changes

暂存变更

git add [file1] [file2] ...
git add [file1] [file2] ...

Commit with generated message

使用生成的信息提交

git commit -m "feat(architecture): implement unified Solver interface
  • Create VRPProblem, VRPSolution, Solver abstract base classes
  • Implement ALNSSolver adapter pattern
  • Update quickstart tutorial to demonstrate new interface"
git commit -m "feat(architecture): implement unified Solver interface
  • Create VRPProblem, VRPSolution, Solver abstract base classes
  • Implement ALNSSolver adapter pattern
  • Update quickstart tutorial to demonstrate new interface"

Push to remote (if desired)

推送到远程仓库(如需)

git push
undefined
git push
undefined

Quick Command Reference

快速命令参考

Status & Diff

状态与差异

bash
git status -s          # Short status
git diff               # Unstaged changes
git diff --staged      # Staged changes
git diff HEAD~1        # Compare with previous commit
bash
git status -s          # 简洁状态显示
git diff               # 未暂存的变更
git diff --staged      # 已暂存的变更
git diff HEAD~1        # 与上一次提交对比

Commit Operations

提交操作

bash
git commit -am "msg"   # Stage tracked files and commit
git commit --amend     # Amend last commit
git commit --amend --no-edit  # Amend without changing message
bash
git commit -am "msg"   # 暂存已跟踪文件并提交
git commit --amend     # 修改上一次提交
git commit --amend --no-edit  # 修改提交但保留原信息

Branch Operations

分支操作

bash
git checkout -b feature-name  # Create and switch branch
git switch -c feature-name    # Modern equivalent
git branch -d branch-name     # Delete local branch
bash
git checkout -b feature-name  # 创建并切换分支
git switch -c feature-name    # 现代等效命令
git branch -d branch-name     # 删除本地分支

History & Log

历史与日志

bash
git log --oneline -10         # Last 10 commits, one line
git log --oneline --graph --all  # Graphical history
git show HEAD                 # Show last commit details
bash
git log --oneline -10         # 最近10条提交,单行显示
git log --oneline --graph --all  # 图形化历史记录
git show HEAD                 # 显示上一次提交详情

Undo & Reset

撤销与重置

bash
git restore --staged file.py  # Unstage file
git restore file.py           # Discard unstaged changes
git reset --soft HEAD~1       # Undo commit, keep changes
bash
git restore --staged file.py  # 取消文件暂存
git restore file.py           # 丢弃未暂存的变更
git reset --soft HEAD~1       # 撤销提交,保留变更

Integration with Other Skills

与其他技能的集成

update-progress: After updating CLAUDE.md and MIGRATION_LOG.md, use git-workflow to commit the documentation updates.
migrate-module: After migrating files, use git-workflow to commit the migrated code.
build-session-context: Read GIT_LOG.md to understand recent changes when starting a session.
update-task-board: Use GIT_LOG.md to track completion of development tasks.
update-progress: 更新CLAUDE.md和MIGRATION_LOG.md后,使用git-workflow提交文档更新。
migrate-module: 迁移文件后,使用git-workflow提交迁移后的代码。
build-session-context: 启动会话时读取GIT_LOG.md以了解近期变更。
update-task-board: 使用GIT_LOG.md跟踪开发任务的完成情况。

Project-Specific Patterns

项目特定模式

Migration Commits

迁移提交

bash
git add vrp_toolkit/problems/pdptw.py
git commit -m "feat(migration): migrate instance.py to pdptw.py

- Extract generic Instance class
- Add type hints and docstrings
- Create basic test suite"
bash
git add vrp_toolkit/problems/pdptw.py
git commit -m "feat(migration): migrate instance.py to pdptw.py

- Extract generic Instance class
- Add type hints and docstrings
- Create basic test suite"

Progress Update Commits

进度更新提交

bash
git add .claude/CLAUDE.md .claude/MIGRATION_LOG.md
git commit -m "chore: update migration progress (5/9 files)

- Mark instance.py migration as completed
- Update progress statistics
- Add detailed migration entry"
bash
git add .claude/CLAUDE.md .claude/MIGRATION_LOG.md
git commit -m "chore: update migration progress (5/9 files)

- Mark instance.py migration as completed
- Update progress statistics
- Add detailed migration entry"

Tutorial/Example Commits

教程/示例提交

bash
git add tutorials/01_quickstart.ipynb
git commit -m "docs: add quickstart tutorial

- Show basic instance creation
- Demonstrate ALNS solving
- Include visualization examples"
bash
git add tutorials/01_quickstart.ipynb
git commit -m "docs: add quickstart tutorial

- Show basic instance creation
- Demonstrate ALNS solving
- Include visualization examples"

GIT_LOG.md Maintenance

GIT_LOG.md维护

Initial Setup

初始设置

If
.claude/GIT_LOG.md
doesn't exist, create it with the structure above.
.claude/GIT_LOG.md
不存在,使用上述结构创建该文件。

Regular Updates

定期更新

After each commit, update GIT_LOG.md with the new commit information.
每次提交后,使用新的提交信息更新GIT_LOG.md。

Archive Strategy

归档策略

  • Keep last 20 commits in "Recent Commits" section
  • Move older commits to "Archive" section at bottom
  • Consider monthly archives if volume is high
  • "Recent Commits"部分保留最近20条提交
  • 将旧提交移至底部的"Archive"部分
  • 若提交量较大,可考虑按月份归档

Automation Notes

自动化说明

When AI uses this skill, it should:
  1. Analyze current git changes
  2. Generate appropriate commit message
  3. Show user exact commands to execute
  4. After commit, update GIT_LOG.md with new entry
  5. Keep GIT_LOG.md organized and readable
AI使用本技能时应:
  1. 分析当前Git变更
  2. 生成合适的提交信息
  3. 向用户展示可直接执行的命令
  4. 提交完成后,在GIT_LOG.md中添加新条目
  5. 保持GIT_LOG.md的整洁与可读性

Troubleshooting

故障排除

Empty Commit Message

提交信息过于通用

If commit message seems generic, ask:
  • What specific functionality was added/fixed?
  • Which files were most significantly changed?
  • What problem does this change solve?
若提交信息看起来过于笼统,询问:
  • 新增/修复了哪些具体功能?
  • 哪些文件的变更最为显著?
  • 此变更解决了什么问题?

Multiple Change Types

包含多种变更类型

If changes include mixed types (e.g., feat and fix):
  • Create separate commits if possible
  • If must combine, use most significant type and explain in body
若变更包含多种类型(例如功能新增与Bug修复):
  • 尽可能拆分为单独的提交
  • 若必须合并,使用最主要的类型并在正文中说明

Missing GIT_LOG.md

缺少GIT_LOG.md

If file doesn't exist, create it with current commit history:
bash
undefined
若文件不存在,使用当前提交历史创建:
bash
undefined

Get last 20 commits for initial log

获取最近20条提交以初始化日志

git log --oneline -20
undefined
git log --oneline -20
undefined