Handles git work: atomic commits, rebase, squash, blame, bisect, reflog, and history questions. Use whenever a task needs a commit or a git-history investigatio
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-git-master-e323b8f83748 ,按照其中的说明把「git-master」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
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.
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.
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.
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 only the user's requested changes. Preserve unrelated dirty work.
git diff --staged --stat and enough staged diff to prove the group is right.git log -1 --oneline.Grouping rules:
Final report: list commit hashes, messages, and any remaining uncommitted files.
History rewriting is a shared-impact operation.
main, master, dev, release branches, or a protected branch unless the user explicitly named that exact operation.--force-with-lease, never plain --force.git commit --fixup=<hash> followed by GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash <base>.git rebase --abort first. 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.
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.git reflog: recover or explain recent local history movement.Always cite the exact command evidence in the answer: commit hash, subject, file path, and line or diff context when relevant. If the evidence is ambiguous, say what remains unproven.
Before any write to Git history:
rebase --abort, reflog hash, or untouched worktree).Before finishing: