AgentSkillsCN

git

Git 操作指南:详尽解析常见 Git 任务的使用方法。 适用场景: - 通过变基编辑提交信息 - 编写符合 Conventional Commits 格式的提交信息 - 理解各类 Git 工作流

SKILL.md
--- frontmatter
name: git
description: |
  Git operations guide. Provides how-to for common git tasks.
  Use when:
  - Editing commit messages via rebase
  - Writing commit messages (Conventional Commits format)
  - Understanding git workflows

Git Skill

Guide for Git operations. For mandatory rules and permissions, see rules/git-github.md.

1. Editing Commit Messages (Rebase)

Edit commit messages in a local branch using interactive rebase.

1.1. Prerequisites

  • Local branch not yet pushed
  • Automate interactive operations with environment variables
  • Understand that hash values will change

1.2. Steps

sh
# 1. Find the commit hash to edit
git log --oneline -10

# 2. Start rebase with "edit" via environment variable
GIT_SEQUENCE_EDITOR="sed -i '' 's/^pick <HASH>/edit <HASH>/'" git rebase -i <HASH>^

# 3. Edit the commit message
git commit --amend --allow-empty --no-verify -m "New message"

# 4. Continue rebase (get user permission)
git rebase --continue

1.3. Notes

  • Interactive rebase (-i flag) is allowed but must be automated
  • Always get user permission before git rebase --continue
  • Do not use on pushed commits as hash values change

2. Commit Message Format (Conventional Commits)

text
<type>: <brief description> (#<Issue number>)

<detailed description>

## Summary

- Same as detailed description is OK

## Background

- Briefly explain the background and purpose

## Changes

- Specific change 1
- Specific change 2

## Technical Details

- Technical implementation details
- Reasons for design decisions
- Focus on "why" throughout

## Verification

- Describe verification if performed

## Related URLs

- <Related Issue>
- <External URL>
- Others if applicable

2.1. Type Examples

TypeDescription
featNew feature
fixBug fix
docsDocumentation only
styleFormatting, no code change
refactorCode change without fix/feat
testAdding/updating tests
choreMaintenance, dependencies

3. Related Resources

ResourcePurpose
rules/git-githubMandatory rules and permissions
skills/githubGitHub-specific operations