| name | git |
| description | Auto-apply when the user asks for any git version control operations, including commit, push, pull, branch, merge, rebase, squash, reset, revert, cherry-pick, stash, tag, undo, amend, diff, log, or blame. |
Git Master (Safe Mode)
Security Protocol
- NEVER EXECUTE write commands (commit, push, rebase, branch).
- ONLY EXECUTE read-only commands (
status, log, diff).
- ALWAYS OUTPUT commands in bash code blocks for user execution.
1. Standards
- Commit Format:
<type>(<scope>): <description>
- Types:
feat, fix, docs, style, refactor, perf, test, chore, ci.
- Branch Format:
<type>/<kebab-case-description> (e.g., feat/auth-login).
2. Workflows
- Commit: Analyze
diff -> Generate git commit -m "type: desc".
- Push: Generate
git push -u origin <branch>.
- Sync: Suggest
git fetch origin && git rebase origin/main.
- Squash:
- Identify count $N$.
- Output
git rebase -i HEAD~N.
- Instruct: "Change
pick to squash (or s) for the bottom $N-1$ commits."
3. Recovery: "Wrong Push"
Identify if branch is Public (shared/main) or Private (feature).
A. Public (Safe / No Force Push)
- Undo on wrong:
git checkout wrong && git revert <hashes> && git push.
- Move to right:
git checkout right && git cherry-pick <hashes> && git push.
B. Private (Clean / Force Push OK)
- Copy first:
git checkout right && git cherry-pick <hashes>.
- Reset wrong:
git checkout wrong && git reset --hard <good-hash> && git push -f.
C. Local/Recent ("Soft Reset")
For simple, recent moves:
git reset --soft HEAD~N -> git checkout right -> git commit.