git-master
它能做什么
这个代理可以借助 Git 帮你管理代码的版本历史。它可以完成这些工作:用清晰的描述保存你的修改(提交,即 commit),整理修改历史,并回答关于谁在什么时候改了什么的问题。
适用场景
- ✓当你需要保存一组代码修改时。
- ✓当你想理解或重新整理代码的修改历史时。
- ✓当你需要查明某处代码是谁修改的时。
技能链接
https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/git-master/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“把我最近的修改保存为一次提交,提交信息写“添加登录功能”。”
每周 5 个新技能,1 分钟读完。
工作原理
它会分析你的指令,并使用 Git 工具执行相应操作,比如创建提交、重新整理历史,或获取过去修改的信息。行动前,它会先检查当前代码的状态。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Git Master
Use this skill when the user asks you to operate on Git history or answer a Git-history question. Be exact, conservative, and evidence-led. Read the repository state before you infer anything.
Mode Gate
Classify the request first:
COMMIT: stage and commit local changes.REBASE: rebase, squash, fixup, autosquash, reorder, split, or otherwise rewrite branch history.HISTORY: answer when, where, who, why, or which commit changed something.STATUS: inspect branch, diff, or working-tree state without changing it.
Do not commit, rebase, push, force-push, reset, stash-pop, or delete anything unless the user explicitly asked for that operation. If the request is only investigative, report findings and stop.
Ground Truth
Gather independent facts in parallel when the tools allow it:
git status --short
git diff --stat
git diff --staged --stat
git branch --show-current
git log -30 --oneline
git log -30 --pretty=format:%s
git rev-parse --abbrev-ref @{upstream}
git merge-base HEAD origin/main
git merge-base HEAD origin/master
Missing upstream or missing main/master is normal. Fall back to the best available branch or report the missing fact. Never treat a failed lookup as proof.
PR Body Evidence Attachments
When a PR body needs screenshots or terminal PNGs, use the repo reference at docs/reference/github-attachment-upload.md. The allowed hosting path is GitHub user attachments from the authenticated web attachment flow; never commit temporary images, never use GitHub Releases for PR evidence, and never use external image hosts. Do not log browser cookies, CSRF tokens, S3 form fields, or upload headers.
Commit Mode
Commit only the user's requested changes. Preserve unrelated dirty work.
- Detect message style from recent history. Use the dominant local pattern, language, and casing. Do not default to Conventional Commits unless the repo uses them.
- Inspect the full diff, not only filenames. Separate unrelated user edits from the requested commit.
- Build atomic groups by behavior, module, and revertability. Keep implementation and its direct tests together.
- Prefer multiple commits for unrelated concerns. A single commit is acceptable only when the changed files form one indivisible behavior or the user explicitly asks for one commit.
- Stage by path or hunk so each commit contains only its atomic group.
- Before each commit, verify
git diff --staged --statand enough staged diff to prove the group is right. - Commit with the detected style. After each commit, verify
git log -1 --oneline.
Grouping rules:
- Split different features, modules, generated artifacts, config, docs, and test-only changes unless they are inseparable.
- Keep generated files with the source change that produced them when omitting them would leave the repo inconsistent.
- Never hide failing or unrelated changes inside a broad commit.
Final report: list commit hashes, messages, and any remaining uncommitted files.
Rebase Mode
History rewriting is a shared-impact operation.
- Never rebase or rewrite
main,master,dev, release branches, or a protected branch unless the user explicitly named that exact operation. - If commits may already be pushed, ask before force-pushing. Use
--force-with-lease, never plain--force. - If the worktree is dirty, preserve it intentionally before rebasing. Do not stash-pop over conflicts without checking what changed.
- For fixups, prefer
git commit --fixup=<hash>followed byGIT_SEQUENCE_EDITOR=: git rebase -i --autosquash <base>. - For conflicts, read the conflicting files and resolve by intent. Do not choose ours/theirs blindly.
- If a rebase goes wrong, use
git rebase --abortfirst. Use reflog only after explaining the recovery path.
After rewriting, run the relevant tests or at least the project's cheapest smoke check, then show the new branch log from base to HEAD.
History Mode
Choose the Git tool by the question:
git log -S "text": when the count of an exact string changed.git log -G "regex": when diffs touched lines matching a pattern.git blame -L start,end -- file: who last changed specific lines.git log --follow -- file: history across renames for one file.git show <hash>: inspect the commit that appears relevant.git bisect: find the first bad commit when there is a deterministic pass/fail command and known good/bad bounds.
…
常见问题
“atomic commit”是什么?
它指的是只聚焦于单一任务或单一修复的一次保存,这样历史记录更容易理解和管理。
“重写历史”是什么意思?
指修改已经完成的提交,比如把几个提交合并成一个,或调整它们的顺序。这一操作需要谨慎进行。
如果我没有要求保存,Git 会做什么?
如果你只是询问历史相关的问题或要求查看状态,它只会提供信息,不会做任何修改。
详情
作者的原始描述
Handles git work: atomic commits, rebase, squash, blame, bisect, reflog, and history questions. Use whenever a task needs a commit or a git-history investigation; skip for ordinary code edits.
热度
- GitHub 星标
- 70k
- 排名
- #3134
- 许可证
- NOASSERTION
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
comment-checker
70k帮你的智能体理解并回应自动代码检查工具的反馈。适用于处理自动化代码或内容审查的结果。
lcx-contribute-bug-fix
70k帮你的智能体为 LazyCodex 相关项目贡献错误修复。它会创建 issue 或 pull request,保障代码质量。
lcx-doctor
70k让你的智能体检查 LazyCodex 和 Codex CLI 安装的健康状况。当系统在更新或改动后表现异常时很有用。
lcx-report-bug
70k帮你的智能体为 LazyCodex 项目详细报告 bug。它会创建包含有用信息的 issue,方便开发者定位并修复问题。