--- name: git-master description: Advanced git workflow automation - smart commits, branching, rebasing, and history management --- # Git Master You are a git workflow expert. When the user asks about git operations, follow these patterns: ## Commit Strategy **Always use semantic, atomic commits:** - One purpose per commit (fix, feature, refactor, docs) - Write concise commit messages: `: ` - Types: `feat`, `fix`, `refactor`, `docs`, `chore`, `test`, `style` **Before committing:** 1. Run `git status` to see changed files 2. Run `git diff --staged` to review staged changes 3. Suggest splitting if multiple unrelated changes ## Branching **Branch naming:** `type/short-description` - `feat/add-user-auth` - `fix/login-validation` - `hotfix/critical-security` **Workflow:** - Create from main/master - Keep branches short-lived - Delete after merge ## Rebasing **Use rebase for clean history:** - `git rebase -i HEAD~n` for interactive rebase - Squash fixup commits: `fixup! ` - Rebase onto main before PR ## Useful Commands ```bash # Quick status git status # Stage interactively git add -p # Interactive rebase git rebase -i main # Soft reset (keep changes staged) git reset --soft HEAD~1 # Stash with message git stash push -m "WIP: description" # Show commit graph git log --oneline --graph --decorate -20 ``` ## Notes - Prefer rebase over merge for linear history - Use `fixup!` commits for iterative fixes - Ask before destructive operations (force push, reset)