agentleFS
Laffey-82Laffey-82/cn-agent-skills/skills/git-workflow/SKILL.md

git-workflow

Skill1 starsChanged 3 months agoMITView on GitHub

Git 工作流规范。整理提交历史、规范分支命名、拆分过大的 commit、处理冲突,产出干净可回滚的提交记录。Use to keep git history clean: atomic commits, proper branch naming, rebase, and conflict resolution.

  • Deletes or force-pushes

188 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use squad-commands, ci-cd-pipelines and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • Microsoft AzureSkill

    squad-commands

    Categorized catalog of common Squad operations. Coordinator reads this file and presents it as an interactive menu when the user asks for available commands or help.

    Also in 5 projects that use this

  • harrissohail6Skill

    ci-cd-pipelines

    CI/CD pipeline design and implementation. Auto-activates when discussing deployment, automation, or pipelines.

    Also in 6 projects that use this

  • Microsoft AzureSkill

    architectural-proposals

    How to write comprehensive architectural proposals that drive alignment before code is written

    Also in 4 projects that use this

  • GitHubSkill

    e2e-template-testing

    End-to-end validation of coordinator and agent template changes

    Also in 3 projects that use this

  • GitHubSkill

    notification-routing

    Route agent notifications to specific channels by type — prevent alert fatigue from single-channel flooding

    Also in 3 projects that use this

  • frostneySkill

    native-nostalgia-stack

    Applies the user's FreePascal toolchain and its build, formatting, hook, and test contracts while leaving project-specific mechanics local. Use when scaffolding or working in a FreePascal project that follows this toolchain.

    Also in 3 projects that use this

  • +5 more from Azure
  • +1 more from github

The file

Files
SKILL.md

Git 工作流规范

何时使用

  • 提交历史混乱(一次提交塞了很多改动);
  • 分支命名随意("test""123""new");
  • 用户说"帮我把提交整理干净""squash 一下";
  • 冲突需要处理,或需要规划合并策略。

使用步骤

第 1 步:检查现状

git status
git log --oneline --graph -20   # 最近的提交历史
git branch -a                   # 分支情况

第 2 步:规划目标历史

确定:

  1. 哪些改动应该合并成一个 commit;
  2. 每个 commit 的提交信息(遵循 commit-message-writer 规范);
  3. 是否要拆分成多个 commit。

第 3 步:整理历史

常用操作:

# 合并最近 N 个提交
git rebase -i HEAD~N

# 拆分暂存内容
git add -p

# 修改最近一次提交信息
git commit --amend

原则:

  • 原子提交:一个 commit 只做一件事,可独立回滚;
  • 提交信息遵循 <type>: <subject> 规范;
  • 功能分支命名:feature/<说明>、fix/<说明>、docs/<说明>;
  • 个人分支上优先 rebase 保持线性历史;共享分支禁止改写已推送历史;
  • 合入主干推荐 squash 合并或 rebase 合并,保持主干整洁。

第 4 步:处理冲突

  1. 冲突时逐个文件解决,保留双方合理逻辑;
  2. 解决后执行 git add 并继续 rebase/merge;
  3. 冲突解决后运行测试确认无回归;
  4. 输出冲突解决说明(哪些取舍、依据是什么)。

第 5 步:验证

git log --oneline --graph
git status

确认:历史线性、commit 原子、信息规范、工作区干净。

输入与输出

  • 输入:当前仓库状态 + 期望整理目标;
  • 输出:整理后的提交历史 + 操作记录说明。

示例

用户: "帮我 squash 最近 3 个提交。"

执行:

git rebase -i HEAD~3
# 将后两个 pick 改为 squash

结果:

feat(api): 增加用户注册接口

参考

分支命名、原子提交、rebase/merge 选择和命令速查见 references/GIT_CHEATSHEET.md。

辅助脚本

scripts/git_stats.py 统计最近提交的类型分布、作者分布,标出信息不规范或超长的提交:

python scripts/git_stats.py --count 50

脚本只做统计,结论需要人确认。

注意事项

  • 改写已推送的共享分支历史前必须确认,未经确认不做 push -f;
  • 不执行 git reset --hard、git clean -f 等破坏性命令,除非用户明确要求;
  • 操作前建议备份:记录当前 HEAD 的 hash;
  • 整理历史不等于掩盖问题,提交信息要如实描述改动。

不适用场景

  • 仓库历史是共享且不可改写的(只给建议不动手);
  • 用户只需要一次提交(用 commit-message-writer);
  • 尚未初始化的仓库(先 git init)。

验证方式

  1. 触发:"整理一下提交历史";
  2. 检查:每个 commit 只包含一件事,信息规范,历史线性;
  3. 验证:工作区干净,测试通过。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.