AgentSkillsCN

git-workflow

执行完整的 Git 工作流程,用于协作开发。适用于用户要求初始化仓库、创建分支、提交更改、与上游同步、打开拉取请求、解决冲突、合并 PR、创建发布版本,或应用热修复时使用。支持集中式、功能分支、Gitflow 以及 Forking 工作流程,并遵循常规提交、分支命名规范和代码审查准则。

SKILL.md
--- frontmatter
name: git-workflow
description: 'Execute a complete git workflow for collaborative development. Use when user asks to initialize a repo, create branches, commit changes, sync with upstream, open pull requests, resolve conflicts, merge PRs, create releases, or apply hotfixes. Supports Centralized, Feature Branch, Gitflow, and Forking workflows with conventional commits, branch naming standards, and code review guidelines.'
license: MIT
compatibility: 'Git 2.x, GitHub CLI (gh) for PR commands'
allowed-tools: Bash

Git Workflow

Overview

A complete git workflow skill covering the full development lifecycle — from repository setup through release. Supports four workflow models based on team size and release cadence.

Workflow Models

1. Centralized Workflow

All developers commit directly to main. Best for small teams or SVN migrations.

  • Single branch (main)
  • Pull with rebase to stay linear
  • Conflict resolution before push

2. Feature Branch Workflow

All development happens on dedicated branches. Core idea: main never contains broken code.

  • Create a branch per feature or fix
  • Open a pull request for code review
  • Merge into main after approval

3. Gitflow Workflow

Strict branching model designed around project releases. Extends Feature Branch with release management.

  • main — production-ready code
  • develop — integration branch for features
  • feature/* — new features branch from develop
  • release/* — release preparation branches
  • hotfix/* — urgent fixes branch from main

4. Forking Workflow

Each developer has their own server-side fork. Common in open source.

  • Fork the upstream repository
  • Clone your fork locally
  • Push to your fork, open PRs against upstream

Workflow Selection Guide

CriteriaCentralizedFeature BranchGitflowForking
Team size1–32–105+Any (open source)
Release cadenceContinuousContinuousScheduledVaries
Branch complexityMinimalLowHighMedium
Code reviewOptionalRequiredRequiredRequired
Best forSmall teams, simple projectsMost teamsVersioned releasesOpen source, external contributors

Actions

Step-by-step procedures for each phase of the workflow:

  1. Initialize Repository — Clone, set up remotes, or fork
  2. Create Feature Branch — Create and push a feature branch
  3. Commit Changes — Stage and commit with conventional commits
  4. Sync with Upstream — Pull and rebase to stay current
  5. Create Pull Request — Open a PR for code review
  6. Resolve Merge Conflicts — Handle conflicts during rebase or merge
  7. Merge Pull Request — Merge an approved PR into the target branch
  8. Create Release — Create release branches and tags (Gitflow)
  9. Create Hotfix — Create and merge hotfix branches (Gitflow)

Standards

Conventions and guidelines to follow throughout the workflow:

Git Safety Protocol

  • NEVER update git config without explicit request
  • NEVER run destructive commands (--force, hard reset) without explicit request
  • NEVER skip hooks (--no-verify) unless user asks
  • NEVER force push to main/master/develop
  • If a commit fails due to hooks, fix the issue and create a NEW commit (do not amend)