AgentSkillsCN

Git Workflow

Git工作流

SKILL.md

Git Workflow

Best practices for Git version control and GitHub collaboration.

Branch Strategy

Naming Convention

code
{type}/{description}

Types:
- feat/     New feature
- fix/      Bug fix
- refactor/ Code restructuring
- docs/     Documentation
- test/     Test additions/changes
- chore/    Maintenance tasks

Examples:

  • feat/user-authentication
  • fix/login-redirect-loop
  • refactor/extract-validation

Protected Branches

Never commit directly to:

  • main / master
  • develop
  • release/*

Always use feature branches and pull requests.

Commit Messages

Format

code
type(scope): description

[optional body]

[optional footer]

Types

TypeUse For
featNew feature
fixBug fix
docsDocumentation only
styleFormatting (no logic change)
refactorCode restructuring
perfPerformance improvement
testAdding/fixing tests
choreMaintenance, dependencies

Examples

code
feat(auth): add OAuth2 support for GitHub

fix(api): handle null response in user endpoint

refactor(core): extract validation to separate module

docs(readme): update installation instructions

Rules

  • First line ≤ 72 characters
  • Use imperative mood ("add" not "added")
  • No period at the end
  • Focus on WHY, not WHAT

Common Operations

Start New Feature

bash
git checkout main
git pull origin main
git checkout -b feat/new-feature

Save Work in Progress

bash
git add -A
git commit -m "wip: work in progress"
# Or use stash
git stash push -m "description"

Sync with Main

bash
git fetch origin main
git rebase origin/main
# Or merge if rebasing is problematic
git merge origin/main

Create Pull Request

bash
git push -u origin feat/new-feature
gh pr create --fill

Shell Functions Available

FunctionPurpose
fgcFuzzy branch checkout
fgaFuzzy git add (interactive staging)
fglFuzzy git log
git-rootJump to repository root
git-undoUndo last commit (keep changes)
git-branchesList branches by date
git-cleanupDelete merged branches
aicommitAI-generated commit message

Safety Rules

Never Do (Blocked by Hooks)

  • Force push to protected branches
  • Interactive rebase (requires manual input)
  • Delete protected branches

Ask First (Hook Prompts)

  • git commit --amend - Only if not pushed
  • git reset --hard - Loses uncommitted work
  • git clean -fd - Deletes untracked files
  • Force push to feature branches

GitHub CLI (gh)

bash
# Create PR
gh pr create --title "Title" --body "Description"

# View PR
gh pr view

# Check PR status
gh pr checks

# Merge PR
gh pr merge --squash

# Create issue
gh issue create --title "Bug: ..."