source-control
ABOUTME: Git conventional commit format and version control best practices
ABOUTME: Commit message standards, branch strategies, workflow patterns
Source Control
Quick Reference
git commit -m "feat: add user authentication"
git checkout -b feat/user-auth
git fetch origin && git rebase origin/main
git stash && git stash pop
Conventional Commits
Format: <type>(<scope>): <subject> (scope/body/footer optional)
| Type | Use |
|---|---|
feat |
New feature |
fix |
Bug fix |
docs |
Documentation |
style |
Formatting |
refactor |
Code restructure |
perf |
Performance |
test |
Tests |
chore |
Maintenance |
ci |
CI/CD |
build |
Build system |
revert |
Revert commit |
Rules: Imperative mood, present tense, lowercase, no period, max 50 chars
# Good
git commit -m "feat(auth): add JWT validation"
git commit -m "fix: resolve race condition"
# Bad
git commit -m "Fixed stuff" # Not conventional
git commit -m "Feat: Add thing" # Capital letter
Commit Process
-
Check state:
git status && git diff HEAD && git branch --show-current && git log --oneline -5 -
Verify NOT on main/master (abort if so, unless authorized)
-
Stage specific files (never
git add -A):git add <specific-files> -
Commit with conventional format:
git commit -m "<type>(<scope>): <subject>"
Branch Naming
| Type | Pattern |
|---|---|
| Feature | feat/user-auth, feature/dashboard |
| Fix | fix/login-bug, bugfix/api-error |
| Hotfix | hotfix/security-patch |
| Chore | chore/update-deps |
Workflow
# Start feature
git checkout main && git pull origin main
git checkout -b feat/user-auth
# Keep up to date
git fetch origin && git rebase origin/main
# After PR merged
git checkout main && git pull
git branch -d feat/user-auth
| Use | When |
|---|---|
| Rebase | Keep feature branch current, clean linear history |
| Merge | Integrate to main (via PR), preserve history |
Recovery
| Situation | Command |
|---|---|
| Undo last commit (keep changes) | git reset --soft HEAD~1 |
| Undo staged files | git reset HEAD <file> |
| Discard file changes | git checkout -- <file> |
| Recover deleted branch | git reflog then git checkout -b <branch> <sha> |
| Amend last commit | git commit --amend -m "new message" |
| Revert pushed commit | git revert <sha> |
Conflicts
Resolve: git status to see conflicts, edit files to remove markers, git add <resolved>, then git rebase --continue (or git merge --continue). Use git rebase --abort to bail out.
Hooks
Pre-commit: .git/hooks/pre-commit -- run linters, formatters, tests per language.
Commit-msg: Validate conventional format (commitlint, husky, lefthook).
Best Practices
| DO | DON'T |
|---|---|
| Conventional commits | Generic messages ("fix", "update") |
| Small, logical commits | Huge unrelated changes |
| Run tests before commit | Push broken code |
| Use branches | Commit to main directly |
--force-with-lease |
--force on shared branches |
Resources
- https://www.conventionalcommits.org/
- https://git-scm.com/doc
- Tools: commitlint, husky, lefthook
More from maroffo/claude-forge
email-cleanup
Clean up Gmail - archive old emails, delete promotions, manage storage. Use when user wants to clean inbox, archive emails, or free up space.
25newsletter-digest
Process newsletters into Second Brain digest. Use when user wants to process newsletters, create digest, or catch up on subscriptions. Not for web clippings (use process-clippings) or email bookmarks (use process-email-bookmarks).
22table-image
Render markdown tables as hand-drawn sketch images. Use when user wants a table rendered as an image, visual table, or diagram illustration.
21apple-swift
Apple platform development with Swift, SwiftUI, async/await, and performance. Use when working with .swift files, Package.swift, Xcode projects, or building for iOS/macOS/watchOS/visionOS.
20react-nextjs
React + Next.js App Router development. Use when working with .tsx/.jsx files, next.config, or user asks about Server Components, data fetching, state management, forms, or React testing.
20inbox-triage
Review and prioritize Gmail inbox. Use when user wants to check email, review inbox, or see what needs attention.
19