跳到正文
cccskills
免费在 GitHub 公开中文介绍

git-workflow

帮助团队选择适合开发方式和发布节奏的Git分支策略,统一提交记录与拉取请求说明,并梳理本地历史、合并冲突解决、版本标签和发布管理的操作步骤。

原文查看原文说明

Git workflow patterns including branching strategies, commit conventions, keeping history clean and readable, tidying local commits before merging, merge vs rebase, conflict resolution, and collaborative development best practices for teams of all sizes. Use when choosing a branching strategy, writing commit conventions, cleaning up history before a pull request, deciding merge versus rebase, or resolving conflicts.

AI 评分80分/ 100查看安装方法

适用场景

  • 为新项目选择分支策略
  • 统一提交信息和拉取请求说明
  • 提交审查前整理本地历史
  • 解决合并冲突
  • 管理版本标签与发布

中文介绍

功能

此技能帮助团队制定使用Git的开发流程。它比较GitHub Flow、Trunk-Based Development和GitFlow,说明如何通过分支分别开展修改,为团队按开发方式和发布间隔选择策略提供依据。借助示例和命令,支持编写符合Conventional Commits的提交记录、整理拉取请求说明、清理历史、解决修改冲突,以及管理版本标签。

适用场景

适合为新项目确定Git工作方式,或统一团队的记录格式。也可用于代码审查前整理本地提交历史、选择merge或rebase,以及向新成员介绍团队的操作流程。

使用示例

  • “请为持续发布的小型团队推荐分支策略。”
  • “请整理这次修改的提交信息和拉取请求说明。”
  • “请检查冲突位置,并给出解决步骤。”

注意事项

需要在使用Git的工作中应用。rebase会重写历史,对已经共享的分支,以及其他人已据此开展工作的历史记录,需要谨慎处理。资料建议使用git revert撤销已经发布的修改。内容中也包含会丢弃修改的命令。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

客观评估

AI 仅根据 SKILL.md 的内容,从 4 个方面进行了评估。星标数和热度不计入评估。

指令清晰度能否看出何时使用、做什么
A良好明确列出了分支策略选择、提交信息编写和冲突解决等使用场景。
步骤具体性步骤、输入输出和示例是否具体
A良好提供了分支使用规则、Git命令及提交信息和拉取请求说明模板。
安全性发送数据、删除文件、执行命令等是否有说明
B部分不足说明了强制推送的使用条件,但未提供执行前的确认步骤。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足流程以已有Git和CI为前提,但未说明Git安装或CI配置步骤。

总分按每项 A=25 分、B=15 分、C=5 分相加。 由 AI(OpenAI Codex)于 2026年10月19日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md14.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Git Workflow Patterns

Best practices for Git version control, branching strategies, and collaborative development.

When to Activate

  • Setting up Git workflow for a new project
  • Deciding on branching strategy (GitFlow, trunk-based, GitHub flow)
  • Writing commit messages and PR descriptions
  • Resolving merge conflicts
  • Managing releases and version tags
  • Onboarding new team members to Git practices

Branching Strategies

GitHub Flow (Simple, Recommended for Most)

Best for continuous deployment and small-to-medium teams.

main (protected, always deployable)
  │
  ├── feature/user-auth      → PR → merge to main
  ├── feature/payment-flow   → PR → merge to main
  └── fix/login-bug          → PR → merge to main

Rules:

  • main is always deployable
  • Create feature branches from main
  • Open Pull Request when ready for review
  • After approval and CI passes, merge to main
  • Deploy immediately after merge

Trunk-Based Development (High-Velocity Teams)

Best for teams with strong CI/CD and feature flags.

main (trunk)
  │
  ├── short-lived feature (1-2 days max)
  ├── short-lived feature
  └── short-lived feature

Rules:

  • Everyone commits to main or very short-lived branches
  • Feature flags hide incomplete work
  • CI must pass before merge
  • Deploy multiple times per day

GitFlow (Complex, Release-Cycle Driven)

Best for scheduled releases and enterprise projects.

main (production releases)
  │
  └── develop (integration branch)
        │
        ├── feature/user-auth
        ├── feature/payment
        │
        ├── release/1.0.0    → merge to main and develop
        │
        └── hotfix/critical  → merge to main and develop

Rules:

  • main contains production-ready code only
  • develop is the integration branch
  • Feature branches from develop, merge back to develop
  • Release branches from develop, merge to main and develop
  • Hotfix branches from main, merge to both main and develop

When to Use Which

StrategyTeam SizeRelease CadenceBest For
GitHub FlowAnyContinuousSaaS, web apps, startups
Trunk-Based5+ experiencedMultiple/dayHigh-velocity teams, feature flags
GitFlow10+ScheduledEnterprise, regulated industries

Commit Messages

Conventional Commits Format

<type>(<scope>): <subject>

[optional body]

[optional footer(s)]

Types

TypeUse ForExample
featNew featurefeat(auth): add OAuth2 login
fixBug fixfix(api): handle null response in user endpoint
docsDocumentationdocs(readme): update installation instructions
styleFormatting, no code changestyle: fix indentation in login component
refactorCode refactoringrefactor(db): extract connection pool to module
testAdding/updating teststest(auth): add unit tests for token validation
choreMaintenance taskschore(deps): update dependencies
perfPerformance improvementperf(query): add index to users table
ciCI/CD changesci: add PostgreSQL service to test workflow
revertRevert previous commitrevert: revert "feat(auth): add OAuth2 login"

Good vs Bad Examples

# BAD: Vague, no context
git commit -m "fixed stuff"
git commit -m "updates"
git commit -m "WIP"

# GOOD: Clear, specific, explains why
git commit -m "fix(api): retry requests on 503 Service Unavailable

The external API occasionally returns 503 errors during peak hours.
Added exponential backoff retry logic with max 3 attempts.

Closes #123"

Commit Message Template

Create .gitmessage in repo root:

# <type>(<scope>): <subject>
# # Types: feat, fix, docs, style, refactor, test, chore, perf, ci, revert
# Scope: api, ui, db, auth, etc.
# Subject: imperative mood, no period, max 50 chars
#
# [optional body] - explain why, not what
# [optional footer] - Breaking changes, closes #issue

Enable with: git config commit.template .gitmessage

Merge vs Rebase

Merge (Preserves History)

# Creates a merge commit
git checkout main
git merge feature/user-auth

# Result:
# *   merge commit
# |\
# | * feature commits
# |/
# * main commits

Use when:

  • Merging feature branches into main
  • You want to preserve exact history
  • Multiple people worked on the branch
  • The branch has been pushed and others may have based work on it

Rebase (Linear History)

# Rewrites feature commits onto target branch
git checkout feature/user-auth
git rebase main

# Result:
# * feature commits (rewritten)
# * main commits

Use when:

  • Updating your local feature branch with latest main
  • You want a linear, clean history
  • The branch is local-only (not pushed)
  • You're the only one working on the branch

Rebase Workflow

# Update feature branch with latest main (before PR)
git checkout feature/user-auth
git fetch origin
git rebase origin/main

# Fix any conflicts
# Tests should still pass

# Force push (only if you're the only contributor)
git push --force-with-lease origin feature/user-auth

When NOT to Rebase

# NEVER rebase branches that:
- Have been pushed to a shared repository
- Other people have based work on
- Are protected branches (main, develop)
- Are already merged

# Why: Rebase rewrites history, breaking others' work

Pull Request Workflow

PR Title Format

<type>(<scope>): <description>

Examples:
feat(auth): add SSO support for enterprise users
fix(api): resolve race condition in order processing
docs(api): add OpenAPI specification for v2 endpoints

PR Description Template

## What

Brief description of what this PR does.

## Why

Explain the motivation and context.

## How

Key implementation details worth highlighting.

## Testing

- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed

## Screenshots (if applicable)

Before/after screenshots for UI changes.

## Checklist

- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex logic
- [ ] Documentation updated
- [ ] No new warnings introduced
- [ ] Tests pass locally
- [ ] Related issues linked

Closes #123

Code Review Checklist

For Reviewers:

  • Does the code solve the stated problem?
  • Are there any edge cases not handled?
  • Is the code readable and maintainable?
  • Are there sufficient tests?
  • Are there security concerns?
  • Is the commit history clean (squashed if needed)?

For Authors:

  • Self-review completed before requesting review
  • CI passes (tests, lint, typecheck)
  • PR size is reasonable (<500 lines ideal)
  • Related to a single feature/fix
  • Description clearly explains the change

Conflict Resolution

Identify Conflicts

# Check for conflicts before merge
git checkout main
git merge feature/user-auth --no-commit --no-ff

# If conflicts, Git will show:
# CONFLICT (content): Merge conflict in src/auth/login.ts
# Automatic merge failed; fix conflicts and then commit the result.

Resolve Conflicts

# See conflicted files
git status

# View conflict markers in file
# <<<<<<< HEAD
# content from main
# =======
# content from feature branch
# >>>>>>> feature/user-auth

# Option 1: Manual resolution
# Edit file, remove markers, keep correct content

# Option 2: Use merge tool
git mergetool

# Option 3: Accept one side
git checkout --ours src/auth/login.ts    # Keep main version
git checkout --theirs src/auth/login.ts  # Keep feature version

# After resolving, stage and commit
git add src/auth/login.ts
git commit

Conflict Prevention Strategies

# 1. Keep feature branches small and short-lived
# 2. Rebase frequently onto main
git checkout feature/user-auth
git fetch origin
git rebase origin/main

# 3. Communicate with team about touching shared files
# 4. Use feature flags instead of long-lived branches
# 5. Review and merge PRs promptly

Branch Management

Naming Conventions

# Feature branches
feature/user-authentication
feature/JIRA-123-payment-integration

# Bug fixes
fix/login-redirect-loop
fix/456-null-pointer-exception

# Hotfixes (production issues)
hotfix/critical-security-patch
hotfix/database-connection-leak

# Releases
release/1.2.0
release/2024-01-hotfix

# Experiments/POCs
experiment/new-caching-strategy
poc/graphql-migration

Branch Cleanup

# Delete local branches that are merged
git branch --merged main | grep -v "^\*\|main" | xargs -n 1 git branch -d

# Delete remote-tracking references for deleted remote branches
git fetch -p

# Delete local branch
git branch -d feature/user-auth  # Safe delete (only if merged)
git branch -D feature/user-auth  # Force delete

# Delete remote branch
git push origin --delete feature/user-auth

Stash Workflow

# Save work in progress
git stash push -m "WIP: user authentication"

# List stashes
git stash list

# Apply most recent stash
git stash pop

# Apply specific stash
git stash apply stash@{2}

# Drop stash
git stash drop stash@{0}

Release Management

Semantic Versioning

MAJOR.MINOR.PATCH

MAJOR: Breaking changes
MINOR: New features, backward compatible
PATCH: Bug fixes, backward compatible

Examples:
1.0.0 → 1.0.1 (patch: bug fix)
1.0.1 → 1.1.0 (minor: new feature)
1.1.0 → 2.0.0 (major: breaking change)

Creating Releases

# Create annotated tag
git tag -a v1.2.0 -m "Release v1.2.0

Features:
- Add user authentication
- Implement password reset

Fixes:
- Resolve login redirect issue

Breaking Changes:
- None"

# Push tag to remote
git push origin v1.2.0

# List tags
git tag -l

# Delete tag
git tag -d v1.2.0
git push origin --delete v1.2.0

Changelog Generation

# Generate changelog from commits
git log v1.1.0..v1.2.0 --oneline --no-merges

# Or use conventional-changelog
npx conventional-changelog -i CHANGELOG.md -s

Git Configuration

Essential Configs

# User identity
git config --global user.name "Your Name"
git config --global user.email "your@email.com"

# Default branch name
git config --global init.defaultBranch main

# Pull behavior (rebase instead of merge)
git config --global pull.rebase true

# Push behavior (push current branch only)
git config --global push.default current

# Auto-correct typos
git config --global help.autocorrect 1

# Better diff algorithm
git config --global diff.algorithm histogram

# Color output
git config --global color.ui auto

Useful Aliases

# Add to ~/.gitconfig
[alias]
    co = checkout
    br = branch
    ci = commit
    st = status
    unstage = reset HEAD --
    last = log -1 HEAD
    visual = log --oneline --graph --all
    amend = commit --amend --no-edit
    wip = commit -m "WIP"
    undo = reset --soft HEAD~1
    contributors = shortlog -sn

Gitignore Patterns

# Dependencies
node_modules/
vendor/

# Build outputs
dist/
build/
*.o
*.exe

# Environment files
.env
.env.local
.env.*.local

# IDE
.idea/
.vscode/
*.swp
*.swo

# OS files
.DS_Store
Thumbs.db

# Logs
*.log
logs/

# Test coverage
coverage/

# Cache
.cache/
*.tsbuildinfo

Common Workflows

Starting a New Feature

# 1. Update main branch
git checkout main
git pull origin main

# 2. Create feature branch
git checkout -b feature/user-auth

# 3. Make changes and commit
git add .
git commit -m "feat(auth): implement OAuth2 login"

# 4. Push to remote
git push -u origin feature/user-auth

# 5. Create Pull Request on GitHub/GitLab

Updating a PR with New Changes

# 1. Make additional changes
git add .
git commit -m "feat(auth): add error handling"

# 2. Push updates
git push origin feature/user-auth

Syncing Fork with Upstream

# 1. Add upstream remote (once)
git remote add upstream https://github.com/original/repo.git

# 2. Fetch upstream
git fetch upstream

# 3. Merge upstream/main into your main
git checkout main
git merge upstream/main

# 4. Push to your fork
git push origin main

Undoing Mistakes

# Undo last commit (keep changes)
git reset --soft HEAD~1

# Undo last commit (discard changes)
git reset --hard HEAD~1

# Undo last commit pushed to remote
git revert HEAD
git push origin main

# Undo specific file changes
git checkout HEAD -- path/to/file

# Fix last commit message
git commit --amend -m "New message"

# Add forgotten file to last commit
git add forgotten-file
git commit --amend --no-edit

Git Hooks

Pre-Commit Hook

#!/bin/bash
# .git/hooks/pre-commit

# Run linting
npm run lint || exit 1

# Run tests
npm test || exit 1

# Check for secrets
if git diff --cached | grep -E '(password|api_key|secret)'; then
    echo "Possible secret detected. Commit aborted."
    exit 1
fi

Pre-Push Hook

#!/bin/bash
# .git/hooks/pre-push

# Run full test suite
npm run test:all || exit 1

# Check for console.log statements
if git diff origin/main | grep -E 'console\.log'; then
    echo "Remove console.log statements before pushing."
    exit 1
fi

Anti-Patterns

# BAD: Committing directly to main
git checkout main
git commit -m "fix bug"

# GOOD: Use feature branches and PRs

# BAD: Committing secrets
git add .env  # Contains API keys

# GOOD: Add to .gitignore, use environment variables

# BAD: Giant PRs (1000+ lines)
# GOOD: Break into smaller, focused PRs

# BAD: "Update" commit messages
git commit -m "update"
git commit -m "fix"

# GOOD: Descriptive messages
git commit -m "fix(auth): resolve redirect loop after login"

# BAD: Rewriting public history
git push --force origin main

# GOOD: Use revert for public branches
git revert HEAD

# BAD: Long-lived feature branches (weeks/months)
# GOOD: Keep branches short (days), rebase frequently

# BAD: Committing generated files
git add dist/
git add node_modules/

# GOOD: Add to .gitignore

Quick Reference

TaskCommand
Create branchgit checkout -b feature/name
Switch branchgit checkout branch-name
Delete branchgit branch -d branch-name
Merge branchgit merge branch-name
Rebase branchgit rebase main
View historygit log --oneline --graph
View changesgit diff
Stage changesgit add . or git add -p
Commitgit commit -m "message"
Pushgit push origin branch-name
Pullgit pull origin branch-name
Stashgit stash push -m "message"
Undo last commitgit reset --soft HEAD~1
Revert commitgit revert HEAD

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

accessibility

免费有简介AI 评分 100分

依据WCAG 2.2设计和检查Web、iOS及Android界面,核查读屏标签、键盘操作、配色对比度和操作目标尺寸,使界面支持辅助技术。

  • 为纯图标按钮添加说明
  • 检查键盘操作与模态框焦点
  • 检查对比度与操作目标尺寸
affaan-m/ECC28.4万2026年10月20日 更新

agent-architecture-audit

免费有简介AI 评分 80分

从指令、记忆、工具执行和界面显示等十二个层面排查人工智能代理故障,依据代码和日志梳理原因,按严重程度列出问题并提出修复方案。

  • 排查仅在应用内出现的故障
  • 调查旧对话混入回答的原因
  • 核对工具漏执行或虚报执行
affaan-m/ECC28.4万2026年10月20日 更新

agent-eval

免费有简介AI 评分 80分

用实际开发任务比较多个编程智能体,记录成功率、可获取的API费用、耗时和重复运行的稳定性,为工具选型及更新后的性能评估提供数据。

  • 用实际开发任务比较智能体
  • 采用新工具或模型前进行评估
  • 检查智能体更新后的性能
affaan-m/ECC28.4万2026年10月20日 更新

agent-harness-construction

免费有简介AI 评分 100分

设计和调整AI智能体使用的工具、输入与返回格式,明确出错后的恢复、重试和停止条件,管理上下文信息量,并以完成率、重试次数和成功任务成本评估改进。

  • 设计智能体工具及输入格式
  • 明确工具结果与下一步行动
  • 制定安全重试与停止条件
affaan-m/ECC28.4万2026年10月20日 更新

agent-introspection-debugging

免费有简介AI 评分 100分

根据错误信息和执行环境,分析AI代理反复失败或重复操作的原因。通过小范围、可撤销的恢复操作检验假设,并将结果与依据整理成可供交接的报告。

  • 诊断代理连续失败
  • 调查重复调用工具的循环
  • 检查上下文积累导致的输出退化
affaan-m/ECC28.4万2026年10月5日 更新

agent-introspection-debugging

免费有简介AI 评分 100分

在AI代理反复失败或重复操作时,记录错误与环境前提、排查原因,采取影响有限的恢复操作,并汇总结果和证据,为有依据的重试与交接提供支持。

  • 排查重复调用工具的原因
  • 调查对话膨胀导致的质量下降
  • 核对文件路径与环境差异
affaan-m/ECC28.4万2026年10月20日 更新

查看 affaan-m 的全部技能

报告此技能的问题