git-workflow

GitHub

提供Git协作最佳实践,涵盖分支策略(Trunk-Based/GitFlow)、提交规范(Conventional Commits)及代码审查文化。包含成熟度模型与实操指南,旨在提升版本控制质量与团队协作效率。

categories/development/git-workflow/SKILL.md cosmicstack-labs/mercury-agent-skills

Trigger Scenarios

询问Git分支策略选择 需要制定提交信息规范 寻求代码审查建议 优化Git工作流

Install

npx skills add cosmicstack-labs/mercury-agent-skills --skill git-workflow -g -y
More Options

Non-standard path

npx skills add https://github.com/cosmicstack-labs/mercury-agent-skills/tree/main/categories/development/git-workflow -g -y

Use without installing

npx skills use cosmicstack-labs/mercury-agent-skills@git-workflow

指定 Agent (Claude Code)

npx skills add cosmicstack-labs/mercury-agent-skills --skill git-workflow -a claude-code -g -y

安装 repo 全部 skill

npx skills add cosmicstack-labs/mercury-agent-skills --all -g -y

预览 repo 内 skill

npx skills add cosmicstack-labs/mercury-agent-skills --list

SKILL.md

Frontmatter
{
    "name": "git-workflow",
    "metadata": {
        "tags": [
            "git",
            "version-control",
            "branching",
            "code-review",
            "collaboration"
        ],
        "author": "cosmicstack-labs",
        "version": "1.0.0",
        "category": "development"
    },
    "description": "Git best practices, branching strategies, commit conventions, and code review patterns"
}

Git Workflow

Master the fundamentals of version control collaboration — from branching strategy to commit hygiene to review culture.

Core Principles

1. Commits Are Communication

Every commit message is a message to your future self and your teammates. Write for the reader who needs to understand why a change was made, not just what changed.

2. Branch Intentionally

Your branching strategy should match your team size, release cadence, and deployment model. The best strategy is the one your team actually follows consistently.

3. Review With Empathy

Code review is a conversation, not an inspection. The goal is shared understanding and improved quality, not catching mistakes.

4. Rebase Thoughtfully

History matters. Clean history helps debugging and release management. But never rebase shared branches without team coordination.


Git Workflow Maturity Model

Level Branching Commits Reviews CI
1: Ad-hoc All on main "Update" messages None None
2: Basic Feature branches Some context in messages Occasional Lint checks
3: Standard Trunk-based or GitFlow Conventional commits Required PRs Full test suite
4: Advanced Short-lived branches Atomic, rebased commits Automated + manual Deploy previews
5: Elite Feature flags on trunk Semantic versioning from commits Async + sync pairing Auto-deploy to prod

Target: Level 3+ for team projects. Level 4+ for high-velocity teams.


Actionable Guidance

Branching Strategies

Trunk-Based Development (Recommended for most teams)

  • Main branch: Always deployable. Protected — no direct pushes.
  • Feature branches: Short-lived (1-2 days max). Branch from main, merge back to main.
  • Release branches: Cut from main at release time. Bug fixes cherry-picked.
main:    o---o---o---o---o---o---o
              \         /
feature-A:     o---o---o
                    \
feature-B:         o---o

When to use: Continuous deployment, small teams, mature CI.

GitFlow (For scheduled releases)

  • main: Production releases only
  • develop: Integration branch
  • feature/*: Branch from develop, merge to develop
  • release/*: Branch from develop, merge to main + develop
  • hotfix/*: Branch from main, merge to main + develop

When to use: Scheduled releases, multiple versions in support, larger teams.

Commit Conventions

Conventional Commits (Recommended)

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

[optional body]

[optional footer(s)]

Types: feat, fix, docs, style, refactor, perf, test, chore, ci

feat(auth): add OAuth2 login flow

Implements Google and GitHub OAuth providers.
Closes #142
BREAKING CHANGE: Drops support for password-based auth

Benefits: Automatic changelog generation, semantic versioning, clear intent.

Atomic commits: Each commit should represent one logical change. If you find yourself writing "and" in the description, split the commit.

# Bad: Mixed concerns
"Add user settings page and fix login bug and update deps"

# Good: Three atomic commits
"feat(settings): add user preferences page"
"fix(auth): handle expired session tokens"
"chore(deps): update lodash to 4.17.21"

Code Review Patterns

Review Checklist

For every PR:

  • Does the code solve the stated problem?
  • Are there tests for new functionality?
  • Do existing tests still pass?
  • Is the code at the right abstraction level?
  • Are error paths handled?
  • Are there security concerns (XSS, injection, auth)?
  • Is documentation updated?

Giving Feedback

Bad:  "This is wrong. Do it like this instead."
Good: "I'm concerned about edge cases here — what happens if the user list is empty? Consider using .get() with a default."

Bad:  "This function is too long."
Good: "The validation logic and the rendering logic seem like separate concerns. Could we extract the validation into its own function?"

Review types:

  • Nitpick: Minor style preference, non-blocking. Prefix with "nit:"
  • Suggestion: Alternative approach, discuss. "What do you think about..."
  • Blocking: Must be resolved before merge. Explain why it's critical.
  • Question: Seeking understanding. "I'm trying to understand why..."

Responding to Reviews

  • Don't take feedback personally. Code reviews are about the code, not you.
  • Thank reviewers for catching issues.
  • If you disagree, explain your reasoning — but be open to being wrong.
  • When you make a requested change, resolve the conversation.
  • If something is deliberately chosen, explain (and document) the tradeoff.

Git Hygiene

Before You Commit

# Stage related changes only
git add -p   # Interactive staging — commit only what's relevant

# Review your diff before committing
git diff --staged

# Write the commit message first, then commit
git commit    # Opens editor — write a good message

Before You Push

# Rebase on latest main
git fetch origin
git rebase origin/main

# Check what you're about to push
git log origin/main..HEAD

# Squash fixup commits
git rebase -i origin/main

Pull Request Best Practices

  • Keep PRs small: <400 lines ideal. Large PRs get shallow reviews.
  • One concern per PR: Don't refactor 10 files and add a feature in the same PR.
  • Write a good description: What, why, how, testing, screenshots.
  • Self-review first: Go through your own diff before requesting review.
  • Respond promptly: Don't let PRs languish for days.

Common Mistakes

  1. Committing secrets: Never commit API keys, passwords, or tokens. Use .env files and secret managers.
  2. Large untracked files: Check your .gitignore. Don't commit node_modules, build artifacts, or generated files.
  3. Merge commits in a clean-history workflow: If your team prefers linear history, rebase instead of merging.
  4. Forcing pushes to shared branches: git push --force is dangerous on shared branches. Use --force-with-lease.
  5. Reviewing too late: Review within 24 hours. Stale PRs create context-switching overhead.
  6. Merging failing CI: Never merge a PR with failing checks, even if "it works on my machine."
  7. Descriptions are useless: "Fix bug" tells no one anything. "Fix timeout in user search when database has >10k records" tells everything.

Version History

  • 38e2523 Current 2026-07-05 19:38

Same Skill Collection

categories/ai-ml/agent-audit-logging/SKILL.md
categories/ai-ml/agent-handoff-protocols/SKILL.md
categories/ai-ml/agent-health-monitoring/SKILL.md
categories/ai-ml/agent-task-delegation/SKILL.md
categories/ai-ml/ai-agent-design/SKILL.md
categories/ai-ml/error-recovery-retry/SKILL.md
categories/ai-ml/memory-management/SKILL.md
categories/ai-ml/prompt-engineering/SKILL.md
categories/ai-ml/prompt-version-management/SKILL.md
categories/ai-ml/token-budget-tracking/SKILL.md
categories/automation/daily-briefing/SKILL.md
categories/automation/screenshot/SKILL.md
categories/automation/shell-scripting/SKILL.md
categories/automation/twitter-account-manager/SKILL.md
categories/automation/workflow-automation/SKILL.md
categories/automation/x-twitter-automation/SKILL.md
categories/backend/api-design/SKILL.md
categories/backend/authentication-authorization/SKILL.md
categories/backend/caching-strategies/SKILL.md
categories/backend/database-design/SKILL.md
categories/backend/message-queues/SKILL.md
categories/backend/microservices/SKILL.md
categories/backend/nodejs-patterns/SKILL.md
categories/backend/python-patterns/SKILL.md
categories/backend/serverless-patterns/SKILL.md
categories/business/event-staffing-compliance/SKILL.md
categories/business/event-staffing-ordering/SKILL.md
categories/business/negotiation/SKILL.md
categories/business/startup-strategy/SKILL.md
categories/career/career-planning/SKILL.md
categories/career/interview-prep/SKILL.md
categories/career/linkedin-optimization/SKILL.md
categories/career/resume-writing/SKILL.md
categories/career/salary-negotiation/SKILL.md
categories/creative-personal-development/content-repurposer/SKILL.md
categories/creative-personal-development/daily-standup-journal/SKILL.md
categories/creative-personal-development/decision-matrix/SKILL.md
categories/creative-personal-development/idea-validator/SKILL.md
categories/creative-personal-development/meeting-note-summarizer/SKILL.md
categories/creative-personal-development/personal-branding-statement/SKILL.md
categories/creative-personal-development/storytelling-advisor/SKILL.md
categories/creative-personal-development/time-blocking-scheduler/SKILL.md
categories/data/data-pipeline/SKILL.md
categories/design/accessibility/SKILL.md
categories/design/ui-design-system/SKILL.md
categories/development/api-documentation/SKILL.md
categories/development/architecture-decision-records/SKILL.md
categories/development/clean-code/SKILL.md
categories/development/code-review/SKILL.md
categories/development/debugging-mastery/SKILL.md
categories/development/dependency-management/SKILL.md
categories/development/documentation-generation/SKILL.md
categories/development/hyperframes-cli/SKILL.md
categories/development/hyperframes-media/SKILL.md
categories/development/knowledge-base/SKILL.md
categories/development/markdown-mastery/SKILL.md
categories/development/refactoring-patterns/SKILL.md
categories/development/technical-writing/SKILL.md
categories/development/testing-strategies/SKILL.md
categories/devops/ci-cd-pipeline/SKILL.md
categories/devops/cloud-architecture/SKILL.md
categories/devops/docker-patterns/SKILL.md
categories/devops/kubernetes-patterns/SKILL.md
categories/devops/monitoring-observability/SKILL.md
categories/devops/sre-practices/SKILL.md
categories/devops/terraform-iac/SKILL.md
categories/education-learning/assessment-design/SKILL.md
categories/education-learning/learning-science/SKILL.md
categories/education-learning/micro-learning/SKILL.md
categories/education-learning/teaching-methods/SKILL.md
categories/finance-legal/budgeting-forecasting/SKILL.md
categories/finance-legal/contract-review/SKILL.md
categories/finance-legal/financial-analysis/SKILL.md
categories/finance-legal/privacy-compliance/SKILL.md
categories/finance-legal/risk-management/SKILL.md
categories/frontend/component-design-systems/SKILL.md
categories/frontend/frontend-testing/SKILL.md
categories/frontend/nextjs-patterns/SKILL.md
categories/frontend/react-patterns/SKILL.md
categories/frontend/responsive-design/SKILL.md
categories/frontend/state-management/SKILL.md
categories/frontend/tailwind-css/SKILL.md
categories/frontend/web-performance/SKILL.md
categories/health-wellness/fitness-planning/SKILL.md
categories/health-wellness/habit-formation/SKILL.md
categories/health-wellness/mental-health/SKILL.md
categories/health-wellness/nutrition-planning/SKILL.md
categories/health-wellness/sleep-optimization/SKILL.md
categories/marketing/content-creation/SKILL.md
categories/marketing/local-business-growth/SKILL.md
categories/marketing/seo-strategy/SKILL.md
categories/media-download/audio-extraction/SKILL.md
categories/media-download/github-repo-promo/SKILL.md
categories/media-download/github-repo-tour/SKILL.md
categories/media-download/legal-downloading/SKILL.md
categories/media-download/playlist-archiver/SKILL.md
categories/media-download/video-downloader/SKILL.md
categories/mobile/android-kotlin-patterns/SKILL.md
categories/mobile/app-store-optimization/SKILL.md
categories/mobile/ios-swift-patterns/SKILL.md
categories/mobile/mobile-performance/SKILL.md
categories/mobile/react-native-patterns/SKILL.md
categories/pdf-generation/invoice-document-pdf/SKILL.md
categories/pdf-generation/markdown-to-pdf/SKILL.md
categories/pdf-generation/report-generation/SKILL.md
categories/pdf-generation/typesetting-latex/SKILL.md
categories/presentation/data-storytelling/SKILL.md
categories/presentation/pitch-deck-creation/SKILL.md
categories/presentation/presentation-automation/SKILL.md
categories/presentation/presentation-design/SKILL.md
categories/product/product-strategy/SKILL.md
categories/product/user-research/SKILL.md
categories/security/security-audit/SKILL.md
categories/shop-restaurant/amazon-assistant/SKILL.md
categories/shop-restaurant/daily-pulse/SKILL.md
categories/shop-restaurant/inventory-optimizer/SKILL.md
categories/shop-restaurant/menu-engineer/SKILL.md
categories/shop-restaurant/price-scout/SKILL.md
categories/shop-restaurant/review-responder/SKILL.md
categories/shop-restaurant/social-post/SKILL.md
categories/shop-restaurant/staff-scheduler/SKILL.md
categories/shop-restaurant/table-manager/SKILL.md
categories/shop-restaurant/zomato-order/SKILL.md
categories/testing-qa/accessibility-testing/SKILL.md
categories/testing-qa/api-testing/SKILL.md
categories/testing-qa/e2e-testing/SKILL.md
categories/testing-qa/performance-testing/SKILL.md
categories/testing-qa/test-strategy/SKILL.md
categories/ai-ml/gbrain-lite/SKILL.md
categories/development/hyperframes/SKILL.md
categories/pdf-generation/any2pdf/SKILL.md

Metadata

Files
0
Version
38e2523
Hash
bed2d492
Indexed
2026-07-05 19:38

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-09 03:41
浙ICP备14020137号-1 $Гость$