git-commit-instructions
Practical Git hygiene for staging and committing: review diffs, stage intentionally, avoid committing noise/build artifacts/secrets, and recover from accidental staging or committing. Use when a user asks how to commit changes, write a commit workflow checklist, unstage/remove accidental files, or verify `.gitignore` behavior.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Git Commit Instructions
Overview
Use this checklist to keep commits focused, reviewable, and free of build artifacts and other noise.
Before Every Commit
git status --porcelain
git diff --stat # unstaged changes
git diff --cached --stat # staged changes
Stage Intentionally (preferred)
git add path/to/file.go path/to/dir/
Use git add -A only when you are sure you want every change.
Inspect What Will Be Committed
git diff --cached --name-only
Commit Pattern
git commit -m "Short summary of change"
git rev-parse HEAD
Never Commit (common noise)
Avoid committing:
-
node_modules/,vendor/ -
dist/,build/,out/ -
.env,.env.local - binaries (
*.exe,*.bin, etc.) - logs (
*.log) - OS/IDE junk (
.DS_Store,Thumbs.db,.idea/,.vscode/unless shared) - test artifacts (
coverage/,*.cover) - temp dirs (
tmp/,temp/)
Quick Checks
git status --ignored
git check-ignore -v path/to/file
If You Accidentally Staged Something
git reset HEAD path/to/file # unstage one file
git reset HEAD # unstage everything
If Noise Got Committed
git rm --cached path/to/noise
echo "path/to/noise" >> .gitignore
git add .gitignore
git commit --amend --no-edit # if it was the last commit
Reference
Load references/git-commit-instructions.md for the full command list and recovery patterns.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-02-05
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!