microwind/ai-skills/git-workflows

Claude Code and agent skill by microwind/ai-skills

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

当管理Git工作流时,分析分支策略,优化协作流程,解决合并冲突。验证工作流架构,设计CI/CD集成,和最佳实践。

Install

npx vskill@latest install microwind/ai-skills/git-workflows

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as microwind/ai-skills/git-workflows.

Git工作流管理技能

概述

Git工作流是团队协作开发的核心机制,合理的分支策略和工作流程能够提高开发效率、降低冲突风险、保证代码质量。不当的工作流设计会导致合并困难、版本混乱、协作效率低下。

核心原则: 好的Git工作流应该清晰易懂、适合团队规模、支持持续集成、便于代码审查。坏的工作流会导致分支混乱、冲突频发、部署困难。

何时使用

始终:

  • 团队协作开发时
  • 多人维护同一项目时
  • 需要代码审查时
  • 持续集成/持续部署时
  • 版本发布管理时
  • 热修复紧急部署时

触发短语:

  • "如何选择Git工作流?"
  • "分支策略怎么设计?"
  • "合并冲突怎么解决?"
  • "代码审查流程"
  • "发布版本管理"
  • "热修复怎么处理?"

Git工作流管理技能功能

分支策略
  • Git Flow工作流
  • GitHub Flow工作流
  • GitLab Flow工作流
  • 主干开发模式
  • 功能分支策略
  • 发布分支管理
协作流程
  • 代码审查机制
  • 合并请求管理
  • 冲突解决策略
  • 提交信息规范
  • 版本标签管理
  • 热修复流程
CI/CD集成
  • 自动化测试
  • 构建流水线
  • 部署策略
  • 环境管理
  • 回滚机制
  • 监控告警
团队管理
  • 权限控制
  • 分支保护
  • 提交规范
  • 代码质量检查
  • 发布流程
  • 文档管理

常见问题

❌ 分支策略混乱

  • 分支命名不规范
  • 分支生命周期管理不当
  • 合并策略不统一
  • 长期分支积累过多

❌ 合并冲突频发

  • 功能开发重叠
  • 代码同步不及时
  • 缺乏代码审查
  • 重构操作不当

❌ 版本管理混乱

  • 标签使用不规范
  • 版本号不统一
  • 发布流程不清晰
  • 热修复处理不当

❌ 团队协作低效

  • 提交信息不规范
  • 代码审查缺失
  • 权限管理不当
  • 文档维护不足

代码示例

Git Flow工作流配置
bash
#!/bin/bash
# Git Flow 初始化脚本
setup_git_flow() {
echo "初始化Git Flow工作流..."
# 安装git-flow工具
if command -v brew &> /dev/null; then
brew install git-flow-avh
elif command -v apt &> /dev/null; then
sudo apt-get install git-flow
else
echo "请手动安装git-flow工具"
return 1
fi
# 初始化git flow
git flow init -d
# 设置分支前缀
git config gitflow.branch.feature "feature/"
git config gitflow.branch.release "release/"
git config gitflow.branch.hotfix "hotfix/"
git config gitflow.branch.support "support/"
git config gitflow.prefix.versiontag "v"
echo "Git Flow初始化完成!"
}
# 创建功能分支
create_feature_branch() {
local feature_name=$1
echo "创建功能分支: $feature_name"
# 确保在develop分支
git checkout develop
git pull origin develop
# 创建功能分支
git flow feature start $feature_name
# 推送到远程
git flow feature publish $feature_name
echo "功能分支 $feature_name 创建完成"
}
# 完成功能开发
finish_feature_branch() {
local feature_name=$1
echo "完成功能分支: $feature_name"
# 切换到功能分支
git checkout feature/$feature_name
# 确保代码最新
git pull origin feature/$feature_name
# 运行测试
run_tests
# 完成功能分支
git flow feature finish $feature_name
# 推送到远程
git push origin develop
echo "功能分支 $feature_name 已合并到develop"
}
# 创建发布分支
create_release_branch() {
local version=$1
echo "创建发布分支: $version"
# 确保在develop分支
git checkout develop
git pull origin develop
# 创建发布分支
git flow release start $version
# 推送到远程
git flow release publish $version
echo "发布分支 $version 创建完成"
}
# 完成发布
finish_release_branch() {
local version=$1
echo "完成发布: $version"
# 更新版本号
update_version_number $version
# 完成发布分支
git flow release finish $version
# 推送标签和主分支
git push origin main
git push origin develop
git push origin v$version
echo "发布 $version 完成"
}
# 创建热修复分支
create_hotfix_branch() {
local hotfix_name=$1
echo "创建热修复分支: $hotfix_name"
# 确保在main分支
git checkout main
git pull origin main
# 创建热修复分支
git flow hotfix start $hotfix_name
# 推送到远程
git flow hotfix publish $hotfix_name
echo "热修复分支 $hotfix_name 创建完成"
}
# 运行测试
run_tests() {
echo "运行测试..."
# 这里添加具体的测试命令
npm test || pytest || mvn test
}
# 更新版本号
update_version_number() {
local version=$1
echo "更新版本号到: $version"
# 更新package.json
if [ -f "package.json" ]; then
npm version $version --no-git-tag-version
fi
# 更新其他版本文件
# 根据项目需要添加更多版本文件更新逻辑
}
GitHub Flow工作流
bash
#!/bin/bash
# GitHub Flow 工作流脚本
# 创建功能分支
create_gh_feature() {
local feature_name=$1
local base_branch=${2:-main}
echo "在GitHub Flow中创建功能分支: $feature_name"
# 确保本地代码最新
git checkout $base_branch
git pull origin $base_branch
# 创建并切换到功能分支
git checkout -b feature/$feature_name
# 推送到远程
git push -u origin feature/$feature_name
echo "功能分支创建完成,可以开始开发了"
}
# 提交代码规范检查
commit_with_validation() {
local message=$1
echo "验证提交..."
# 运行代码格式检查
run_linter
# 运行测试
run_tests
# 检查提交信息格式
validate_commit_message "$message"
# 添加所有更改
git add .
# 提交
git commit -m "$message"
echo "提交完成"
}
# 验证提交信息格式
validate_commit_message() {
local message=$1
# 检查提交信息格式
if [[ ! "$message" =~ ^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,50} ]]; then
echo "错误: 提交信息格式不符合规范"
echo "格式: type(scope): description"
echo "类型: feat, fix, docs, style, refactor, test, chore"
exit 1
fi
}
# 创建Pull Request
create_pull_request() {
local feature_branch=$1
local base_branch=${2:-main}
local title=$3
local body=$4
echo "创建Pull Request..."
# 使用GitHub CLI创建PR
if command -v gh &> /dev/null; then
gh pr create \
--base $base_branch \
--head $feature_branch \
--title "$title" \
--body "$body" \
--assignee @me
else
echo "请手动在GitHub上创建Pull Request"
echo "分支: $feature_branch -> $base_branch"
echo "标题: $title"
fi
}
# 自动化部署检查
check_deploy_status() {
local pr_number=$1
echo "检查部署状态..."
# 使用GitHub CLI检查PR状态
if command -v gh &> /dev/null; then
gh pr view $pr_number --json statusCheckRollup --jq '.statusCheckRollup'
fi
}
# 合并到主分支
merge_to_main() {
local feature_branch=$1
echo "合并到主分支..."
# 切换到主分支
git checkout main
git pull origin main
# 合并功能分支
git merge --no-ff feature/$feature_branch
# 推送主分支
git push origin main
# 删除功能分支
git branch -d feature/$feature_branch
git push origin --delete feature/$feature_branch
echo "合并完成"
}
# 运行代码检查
run_linter() {
echo "运行代码检查..."
# JavaScript/TypeScript
if [ -f "package.json" ]; then
npm run lint || echo "警告: 代码检查发现问题"
fi
# Python
if [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
flake8 . || echo "警告: 代码检查发现问题"
black --check . || echo "警告: 代码格式不符合规范"
fi
}
Git工作流自动化脚本
python
#!/usr/bin/env python3
import subprocess
import sys
import json
import re
from datetime import datetime
from typing import List, Dict, Optional

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
50
Repository forks
13
7-day trend score
20

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/microwind/ai-skills/git-workflows/badge)](https://verified-skill.com/skills/microwind/ai-skills/git-workflows)

Something wrong with this skill or its page? Tell us.