AgentSkillsCN

git-strategy

Git Flow分支模型、Conventional Commits格式以及合并策略

SKILL.md
--- frontmatter
name: git-strategy
description: Git Flow branching model, Conventional Commits format, and merge strategy
triggers:
  - git flow
  - branch
  - commit message
  - conventional commit
  - merge strategy
argument-hint: ""

Git branching strategy

Overview

This project follows the Git Flow branching model. All branching, merging, and release workflows must adhere to these rules.

Key Principle: Use Git Flow branches, Conventional Commits, and merge commits for all integrations. Rebase only when updating feature branches from develop.

Note: Use git-flow-next for automated branch management.

Branch structure

code
main (production)
 |
 +-- hotfix/xxx -------------- merge back to main + develop
 |
 develop (integration)
  |
  +-- feature/xxx ------------- merge back to develop
  |
  +-- release/x.x.x ---------- merge back to main + develop
  |
  +-- support/x.x ------------ long-term support for older versions

Branch types

BranchBaseMerges IntoNamingPurpose
main--mainProduction-ready code
developmain-developIntegration branch for features
feature/*developdevelopfeature/{description}New features and enhancements
release/*developmain + developrelease/{version}Release preparation
hotfix/*mainmain + develophotfix/{description}Critical production fixes
support/*main-support/{version}Long-term support for older versions

Branch naming convention

Format

code
{type}/{description}

Rules

RuleExampleNote
Use lowercasefeature/add-loginNever Feature/Add-Login
Use hyphens as separatorfeature/user-authenticationNever underscores or spaces
Keep it short and descriptivehotfix/fix-null-pointerDescribe what, not how
Include Jira ticket when availablefeature/PROJ-123-add-loginTicket number before description

Examples

bash
# Feature
feature/user-authentication
feature/PROJ-123-add-export-api

# Release
release/1.2.0

# Hotfix
hotfix/fix-payment-timeout
hotfix/PROJ-456-null-pointer

# Support
support/1.0

Workflow

Feature development

bash
# 1. Start feature from develop
git flow feature start user-authentication

# 2. Work on feature (commit frequently)
git add . && git commit -m "feat: add user authentication"

# 3. Publish feature for collaboration (optional)
git flow feature publish user-authentication

# 4. Finish feature (merges into develop)
git flow feature finish user-authentication

Release

bash
# 1. Start release from develop
git flow release start 1.2.0

# 2. Final adjustments (version bump, changelog)
git commit -m "chore: bump version to 1.2.0"

# 3. Finish release (merges into main + develop, creates tag)
git flow release finish 1.2.0

Hotfix

bash
# 1. Start hotfix from main
git flow hotfix start fix-payment-timeout

# 2. Fix the issue
git commit -m "fix: resolve payment timeout issue"

# 3. Finish hotfix (merges into main + develop, creates tag)
git flow hotfix finish fix-payment-timeout

Commit message convention

Follow Conventional Commits format:

code
{type}({scope}): {description}

{body}

{footer}

Types

TypeDescriptionExample
featNew featurefeat(auth): add JWT authentication
fixBug fixfix(payment): resolve timeout issue
docsDocumentationdocs: update API documentation
styleFormatting (no logic change)style: fix indentation
refactorCode refactoringrefactor(user): extract validation logic
perfPerformance improvementperf(query): optimize search query
testAdd or fix teststest(auth): add login test cases
choreBuild, CI, toolingchore: update gradle dependencies
buildBuild system changesbuild: upgrade spring boot to 4.0.2
ciCI/CD changesci: add deployment workflow

Rules

  • Use imperative mood: "add" not "added" or "adds"
  • Do not capitalize first letter after type
  • No period at the end of subject line
  • Keep subject line under 72 characters
  • Use body to explain "what" and "why", not "how"

Examples

code
feat(export): add Excel multi-sheet support

Add automatic sheet splitting when row count exceeds Excel limit.
Support MULTI_SHEET and EXCEPTION overflow strategies.

Closes PROJ-789
code
fix(cache): resolve cache eviction race condition

The two-tier cache (Caffeine + Redis) had a race condition
where L1 eviction could serve stale data before L2 update.

Merge strategy

ScenarioStrategyReason
Feature to DevelopMerge commitPreserve feature history
Release to MainMerge commitClear release boundary
Release to DevelopMerge commitSync release fixes
Hotfix to MainMerge commitClear hotfix boundary
Hotfix to DevelopMerge commitSync hotfix
Update feature from developRebaseKeep feature history linear

Tag convention

FormatExampleWhen
v{major}.{minor}.{patch}v1.2.0Release finish
v{major}.{minor}.{patch}v1.2.1Hotfix finish

Follow Semantic Versioning:

  • Major: Breaking changes
  • Minor: New features (backward compatible)
  • Patch: Bug fixes (backward compatible)

Protected branches

BranchPushForce PushDelete
mainPR onlyProhibitedProhibited
developPR onlyProhibitedProhibited
release/*DirectProhibitedAfter merge
feature/*DirectAllowedAfter merge
hotfix/*DirectAllowedAfter merge

Summary checklist

Before merging, verify:

  • Branch follows naming convention ({type}/{description})
  • Commits follow Conventional Commits format
  • Feature branches are based on develop
  • Hotfix branches are based on main
  • Release branches are tagged with semantic version
  • No direct pushes to main or develop
  • Branch is deleted after merge