brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
version-controlExpert guidance for Git version control, trunk-based development workflows, and GitHub best practices. Emphasizes Conventional Commits for clean history, short-lived feature branches, frequent integration, and professional collaboration patterns. Use when users need help with git commands, branching strategies, commit messages, PRs, merge conflicts, or git …
Independent GitHub snapshot · Automated classification · Original documentation governs
Guide users through professional version control practices using Git with trunk-based development, Conventional Commits, and GitHub integration.
Trunk-Based Development:
Conventional Commits:
GitHub Integration:
1. Start from main:
git checkout main
git pull origin main
git checkout -b feat/user-authentication
2. Make small, focused changes:
3. Stay synchronized:
# Update from main frequently
git checkout main
git pull origin main
git checkout feat/user-authentication
git rebase main # Keep history linear
4. Push and create PR:
git push -u origin feat/user-authentication
# Create PR on GitHub
5. After PR approval:
# Squash merge or merge commit to main
# Delete feature branch immediately
git checkout main
git pull origin main
git branch -d feat/user-authentication
Pattern: <type>/<short-description>
Types match Conventional Commit types:
feat/add-oauth-login - New featurefix/authentication-timeout - Bug fixrefactor/database-queries - Code refactoringdocs/api-endpoints - Documentationtest/user-service - Tests onlychore/update-dependencies - MaintenanceKeep descriptions short, lowercase, hyphen-separated.
<type>(<scope>): <subject>
<body>
<footer>
Required: type, subject Optional: scope, body, footer
feat: New feature for users
feat(auth): add OAuth2 authentication
fix: Bug fix
fix(api): handle null response in user endpoint
docs: Documentation changes
docs(readme): update installation instructions
style: Code style/formatting (no logic change)
style(components): fix indentation in Button
refactor: Code restructuring (no behavior change)
refactor(database): extract query builder class
perf: Performance improvement
perf(images): implement lazy loading
test: Adding or updating tests
test(auth): add integration tests for login flow
build: Build system or dependencies
build(deps): upgrade React to v18.2
ci: CI/CD configuration
ci(github): add automated deployment workflow
chore: Maintenance tasks
chore(deps): update development dependencies
revert: Revert previous commit
revert: revert "feat(auth): add OAuth2 authentication"
Optional but recommended. Indicates what part of codebase changed:
feat(api): - API changesfix(ui): - UI fixrefactor(database): - Database refactoringfeat(auth): - Authentication featureUse project-specific scopes that make sense for your codebase.
Good:
feat(api): add user profile endpoint
fix(auth): prevent token expiration race condition
Bad:
feat(api): Added user profile endpoint.
fix(auth): Fixes a bug
Update stuff
feat(search): implement full-text search
- Add PostgreSQL full-text search indexes
- Create search API endpoint with pagination
- Implement search result ranking by relevance
This enables users to search across all content with better
performance than previous LIKE queries.
Breaking changes:
feat(api): change authentication endpoint
BREAKING CHANGE: /auth/login moved to /api/v2/auth/login
Issue references:
fix(ui): prevent modal from closing on backdrop click
Fixes #123
Closes #456
Simple feature:
feat(dashboard): add user activity chart
Bug fix with details:
fix(api): handle network timeout errors
Previously, network timeouts would crash the application.
Now we catch timeout errors and return appropriate error
response to client.
Fixes #789
Breaking change:
feat(api)!: redesign user authentication
BREAKING CHANGE: Auth tokens now expire after 1 hour instead
of 24 hours. Clients must implement token refresh logic.
Multiple changes:
refactor(database): optimize query performance
- Add indexes on frequently queried columns
- Implement connection pooling
- Cache common queries with Redis
- Update ORM configuration for better performance
These changes reduce average query time from 200ms to 50ms.
See references/conventional-commits.md for comprehensive guide.
Check status:
git status # See working tree status
git diff # Show unstaged changes
git diff --staged # Show staged changes
Make commits:
git add <file> # Stage specific file
git add . # Stage all changes
git commit -m "type: message" # Commit with message
git commit # Open editor for commit message
Sync with remote:
git pull origin main # Fetch and merge from main
git push origin <branch> # Push branch to remote
git fetch origin # Fetch without merging
Branch management:
git branch # List local branches
git branch -a # List all branches (including remote)
git checkout -b <branch> # Create and switch to branch
git checkout <branch> # Switch to existing branch
git branch -d <branch> # Delete local branch
Update feature branch from main:
git checkout main
git pull origin main
git checkout feat/my-feature
git rebase main # Keep linear history
# Resolve conflicts if any
git push --force-with-lease origin feat/my-feature
Amend last commit:
git commit --amend # Edit last commit message/content
git commit --amend --no-edit # Add changes to last commit
Unstage changes:
git reset HEAD <file> # Unstage file
git reset HEAD . # Unstage all
Discard changes:
git checkout -- <file> # Discard changes in file
git restore <file> # Modern alternative
git clean -fd # Remove untracked files/dirs
Stash changes:
git stash # Stash working changes
git stash push -m "message" # Stash with message
git stash list # List stashes
git stash apply # Apply most recent stash
git stash pop # Apply and remove stash
git stash drop # Remove stash
View history:
git log # Show commit history
git log --oneline # Compact history
git log --graph # Visual branch graph
git log -p # Show patches
git log --follow <file> # Follow file history
Compare branches:
git diff main..feat/branch # Changes in branch vs main
git log main..feat/branch # Commits in branch not in main
See references/git-commands.md for complete command reference.
1. Push branch:
git push -u origin feat/user-authentication
2. Create PR on GitHub with:
Title: Use Conventional Commit format
feat(auth): add OAuth2 authentication
Description template:
## Summary
Brief description of changes and motivation.
## Changes
- List key changes
- Use bullet points
- Be specific
## Testing
How to test these changes:
1. Step-by-step instructions
2. Expected behavior
## Screenshots (if UI changes)
[Add screenshots]
## Checklist
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] No breaking changes (or documented)
- [ ] Follows Conventional Commits
3. Request reviewers 4. Link related issues
As reviewer:
PR review checklist:
1. Make requested changes:
# Make changes in your branch
git add .
git commit -m "fix(auth): address PR feedback"
git push origin feat/user-authentication
2. Respond to comments 3. Mark conversations as resolved 4. Request re-review
Merge strategies:
Squash and merge (recommended for most features):
Merge commit (for collaborative branches):
Rebase and merge (for clean branches):
After merge:
# Delete remote branch (or use GitHub auto-delete)
git push origin --delete feat/user-authentication
# Update local main
git checkout main
git pull origin main
# Delete local branch
git branch -d feat/user-authentication
See references/github-workflow.md for detailed GitHub guidance.
Configure on GitHub for main branch:
Required:
Recommended:
Optional (for teams):
During merge:
git merge main
# CONFLICT in file.py
During rebase:
git rebase main
# CONFLICT in file.py
1. View conflicts:
git status # Shows conflicted files
2. Open conflicted file:
<<<<<<< HEAD
# Your changes
=======
# Their changes
>>>>>>> main
3. Resolve manually:
4. Mark as resolved:
git add file.py
5. Continue operation:
# For merge:
git commit
# For rebase:
git rebase --continue
6. Abort if needed:
# For merge:
git merge --abort
# For rebase:
git rebase --abort
See references/troubleshooting.md for complex conflict scenarios.
# 1. Ensure main is current
git checkout main
git pull origin main
# 2. Create feature branch
git checkout -b feat/new-feature
# 3. Make changes and commit
git add .
git commit -m "feat(module): add new functionality"
# 4. Push and create PR
git push -u origin feat/new-feature
# Create PR on GitHub
# 1. Create fix branch from main
git checkout main
git pull origin main
git checkout -b fix/bug-description
# 2. Fix and commit
git add .
git commit -m "fix(module): resolve bug description"
# 3. Push and create PR
git push -u origin fix/bug-description
# Create PR with "Fixes #issue-number"
# Option 1: Rebase (preferred for clean history)
git checkout feat/my-feature
git fetch origin
git rebase origin/main
# Resolve conflicts if any
git push --force-with-lease origin feat/my-feature
# Option 2: Merge (preserves branch history)
git checkout feat/my-feature
git fetch origin
git merge origin/main
git push origin feat/my-feature
# If branch too large, split into smaller PRs:
# 1. Create first sub-feature
git checkout -b feat/user-auth-part1 feat/user-auth
git rebase -i main # Mark only first commits as pick
git push -u origin feat/user-auth-part1
# Create PR for part 1
# 2. After part 1 merges, continue with part 2
git checkout main
git pull origin main
git checkout -b feat/user-auth-part2 feat/user-auth
# Continue with remaining commits
✅ Do:
git diff)❌ Don't:
✅ Do:
❌ Don't:
✅ Do:
❌ Don't:
✅ Do:
.gitignore properly❌ Don't:
# Move commit to new branch
git branch feat/new-branch # Create branch at current commit
git reset --hard HEAD~1 # Remove commit from current branch
git checkout feat/new-branch # Switch to new branch
# Keep changes, undo commit
git reset --soft HEAD~1
# Undo commit and changes
git reset --hard HEAD~1
# Undo but keep as uncommitted
git reset HEAD~1
# Remove from last commit
git rm --cached <file>
git commit --amend
git push --force-with-lease
# Remove from history (use tools like BFG Repo-Cleaner)
# Then rotate any exposed secrets!
# Rebase to fix
git fetch origin
git rebase origin/main
# Resolve conflicts
git push --force-with-lease origin feat/my-branch
# Last commit only
git commit --amend
# Older commits
git rebase -i HEAD~3 # For last 3 commits
# Change 'pick' to 'reword' for commits to change
# Abort and start over
git rebase --abort
# Or if already messed up
git reflog # Find previous state
git reset --hard <previous-commit>
See references/troubleshooting.md for more scenarios.
# Rebase last 3 commits interactively
git rebase -i HEAD~3
# Options:
# pick - keep commit
# reword - change commit message
# edit - pause to amend commit
# squash - combine with previous commit
# fixup - like squash but discard message
# drop - remove commit
# Apply specific commit to current branch
git cherry-pick <commit-hash>
# Cherry-pick multiple commits
git cherry-pick <commit1> <commit2>
# Cherry-pick range
git cherry-pick <start>..<end>
# View reference log
git reflog
# Find lost commit
git reflog show HEAD
# Restore to previous state
git reset --hard HEAD@{2}
# Start bisect
git bisect start
git bisect bad # Current commit is bad
git bisect good <commit> # Last known good commit
# Git will checkout middle commit, test it
git bisect good # If works
git bisect bad # If broken
# Repeat until found
git bisect reset # Return to original state
# Create worktree for different branch
git worktree add ../project-feature feat/feature
# List worktrees
git worktree list
# Remove worktree
git worktree remove ../project-feature
See references/advanced-git.md for detailed coverage.
# .github/workflows/ci.yml
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install
run: npm ci
- name: Test
run: npm test
- name: Lint
run: npm run lint
# .github/workflows/commit-lint.yml
name: Commit Lint
on: [pull_request]
jobs:
lint-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v6
See examples/github-actions/ for more workflow examples.
Commit message helpers:
commitizen - Interactive commit message buildercommitlint - Validate commit messageshusky - Git hooks for validationGitHub CLI:
gh pr create --title "feat: add feature" --body "Description"
gh pr checkout 123
gh pr review --approve
gh pr merge --squash
Visual tools:
gitk - Built-in Git GUIUseful git config:
# User info
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Editor
git config --global core.editor "vim"
# Default branch
git config --global init.defaultBranch main
# Rebase by default
git config --global pull.rebase true
# Helpful aliases
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm commit
git config --global alias.lg "log --oneline --graph --decorate"
Activate for requests involving:
Daily Commands:
git status # Check status
git add . # Stage changes
git commit -m "type: message" # Commit
git pull origin main # Update from main
git push origin branch # Push changes
Branch Workflow:
git checkout main # Switch to main
git pull origin main # Update
git checkout -b feat/name # Create branch
# ... make changes ...
git push -u origin feat/name # Push and create PR
Conventional Commit:
type(scope): subject
- Use feat, fix, docs, style, refactor, test, chore
- Imperative mood in subject
- Optional body for details
- Optional footer for breaking changes/issues
Stay Updated:
git fetch origin # Fetch updates
git rebase origin/main # Rebase on main
git push --force-with-lease # Force push safely
Remember: Small commits, frequent integration, clear messages, short-lived branches, and always keep main deployable. This is the path to professional version control.