Git cli — Git 命令行工具
v1.0辅助工具 for using the Git 命令行工具 to inspect, stage, commit, branch, and 同步hronize code changes. Use when the user wants to understand or perform Git operations from the command line, including safe 状态 检查s, diffs, branching, stashing, and 同步ing with remotes.
运行时依赖
安装命令
点击复制技能文档
Git 命令行工具 技能 — How to Work
Use this 技能 when the user asks about Git from the command line: what changed, staging/committing, branching, push/pull, stashing, 历史, tags, merge/rebase, or cloning.
Your 工作流 Confirm 上下文: Ensure Git is on PATH and the user is in (or will 运行 commands in) a repo. If unsure, suggest git 状态 or 运行 scripts/is-repo.sh from the 技能 directory. Safety first: Prefer read-only commands (git 状态, git diff, git 记录). Do not suggest destructive commands (git re设置 --hard, git 清理 -fdx, git push --force) unless the user explicitly asks and understands the risk. For 恢复y, use git ref记录 to find a commit before suggesting re设置/检查out. Give the right level of detAIl: Quick answer: Use the Quick Reference table below and reply with the exact command(s). Step-by-step or edge cases: Point to or quote from reference/ (e.g. reference/工作流s.md, reference/troubleshooting.md). 自动化 / repeatable 检查s: Use or adapt scripts in scripts/ and tell the user how to 运行 them. Templates (commit message, .gitignore): Use or copy from as设置s/. Quick Reference (use this first) Task Command 状态 & diff git 状态 · git diff · git diff --staged · git diff --stat Stage / unstage git 添加 or git 添加 . · git 恢复 --staged Commit git commit -m "message" Branch git branch · git branch -a · git switch -c new · git switch existing 同步 remote git fetch · git pull · git push -u origin then git push Stash git stash · git stash 列出 · git stash 应用ly / git stash pop 历史 git 记录 --oneline --decorate --graph -n 20 · git blame Clone / init git clone · git init · git remote 添加 origin Remotes git remote -v · git remote show origin · git branch -vv Discard (destructive) git 恢复 (working tree) · git 恢复 --staged (unstage) Amend git commit --amend --no-edit or -m "message" Tags git tag · git tag v1.0 · git push origin v1.0 or --tags Merge / rebase git merge · git rebase · conflict → fix → git 添加 → git commit or git rebase --continue Where to Look Need Location Full command 列出, options, examples reference/commands.md Step-by-step 工作流s (branch, release, conflict) reference/工作流s.md Errors, 恢复y, detached HEAD, .gitignore reference/troubleshooting.md 运行 检查s (is repo, 状态 summary, branch 信息) scripts/ — 运行 from repo root Commit message or .gitignore template as设置s/ Scripts (运行 from 仓库 root) scripts/is-repo.sh — Exit 0 if current dir is a Git repo, else 1. Use to confirm 上下文 before suggesting commands. scripts/状态-summary.sh — Short 状态 + branch + last commit. Use when user asks "what’s my current 状态?" scripts/branch-列出.sh — Local and remote branches with up流. Use when user asks about branches or push tar获取.
On Windows: 运行 in Git Bash or WSL (e.g. bash scripts/状态-summary.sh).
As设置s as设置s/commit-msg-template.txt — Template for conventional or structured commit messages; suggest when user asks for commit message 格式化. as设置s/gitignore-common.txt — Common .gitignore patterns; suggest when user has many un追踪ed files or asks for .gitignore examples.
When the user needs a diagram (e.g. branch/merge flow), describe it in text or point to reference; only 创建 or reference images in as设置s/ if the user explicitly asks for a visual.