Git workflow best practices including commit messages, branching strategies, pull requests, and collaboration patterns. Use when working with Git version control.
This skill provides guidance on Git workflow best practices to ensure clean commit history, effective collaboration, and maintainable version control in your projects.
Auto-activates when:
Follow the Conventional Commits specification:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Code style changes (formatting, no logic change)refactor: Code refactoring (no feature or bug fix)perf: Performance improvementstest: Adding or updating testsbuild: Build system or dependency changesci: CI/CD configuration changeschore: Other changes (tooling, maintenance)Examples:
feat(auth): add OAuth2 authentication support
Implement OAuth2 authentication flow using the authorization
code grant type. Supports Google and GitHub providers.
Closes #123
fix(api): handle null response from database query
Previously, null responses would cause the API to crash.
Now returns 404 with appropriate error message.
Fixes #456
Use descriptive, hierarchical branch names:
<type>/<issue-number>-<short-description>
Examples:
feature/123-oauth-authenticationfix/456-null-pointer-crashdocs/789-api-documentationrefactor/321-simplify-parserhotfix/999-security-vulnerabilityCommon branching model:
main (production)
├── develop (integration)
│ ├── feature/123-new-feature
│ ├── feature/456-another-feature
│ └── fix/789-bug-fix
├── release/1.2.0
└── hotfix/critical-security-fix
Branch purposes:
main: Production-ready codedevelop: Integration branch for featuresfeature/*: New featuresfix/*: Bug fixesrelease/*: Release preparationhotfix/*: Critical production fixesCreating a feature branch:
git checkout develop
git pull origin develop
git checkout -b feature/123-new-feature
Keeping branch up to date:
git checkout develop
git pull origin develop
git checkout feature/123-new-feature
git rebase develop
Cleaning up merged branches:
git branch -d feature/123-new-feature # Local
git push origin --delete feature/123-new-feature # Remote
## Summary
Brief description of what this PR does and why.
## Changes
- Add new authentication module
- Update user model with OAuth fields
- Add tests for OAuth flow
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
## Related Issues
Closes #123
Relates to #456
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] Tests added/updated
- [ ] All tests passing
# Add changes to previous commit
git add .
git commit --amend --no-edit
# Update commit message
git commit --amend -m "Updated commit message"
Warning: Only amend commits that haven't been pushed!
Clean up commit history:
git rebase -i HEAD~3 # Last 3 commits
Commands:
pick: Keep commit as-isreword: Change commit messagesquash: Combine with previous commitfixup: Like squash, but discard messagedrop: Remove commit# Save changes
git stash push -m "WIP: working on feature"
# List stashes
git stash list
# Apply and remove latest stash
git stash pop
# Apply specific stash
git stash apply stash@{0}
git cherry-pick <commit-hash>
# Multiple commits
git cherry-pick <commit-hash1> <commit-hash2>
# Range of commits
git cherry-pick <start-hash>^..<end-hash>
Discard uncommitted changes:
git restore <file> # Unstaged changes
git restore --staged <file> # Staged changes
git reset --hard HEAD # All changes (DESTRUCTIVE!)
Undo commits:
# Keep changes, undo commit
git reset --soft HEAD~1
# Keep changes in working directory, unstage
git reset HEAD~1
# Discard changes completely (DESTRUCTIVE!)
git reset --hard HEAD~1
Revert commit (safe for shared branches):
git revert <commit-hash> # Creates new commit that undoes changes
# Add upstream remote (one time)
git remote add upstream <original-repo-url>
# Fetch and merge upstream changes
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
# Start merge/rebase
git merge develop # or git rebase develop
# Edit files to resolve conflicts marked by Git
# Mark as resolved
git add <resolved-file>
# Complete merge
git commit # for merge
# or
git rebase --continue # for rebase
# User information
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Default branch name
git config --global init.defaultBranch main
# Rebase by default on pull
git config --global pull.rebase true
# Better log format
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# Common shortcuts
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
# Undo last commit (keep changes)
git config --global alias.undo "reset --soft HEAD~1"
# Delete merged branches
git config --global alias.cleanup "!git branch --merged | grep -v '\\*\\|main\\|develop' | xargs -n 1 git branch -d"
# Install git-secrets
brew install git-secrets # macOS
# Initialize in repo
git secrets --install
git secrets --register-aws
# Scan for secrets
git secrets --scan-history
# Generate GPG key
gpg --gen-key
# Configure Git to use GPG
git config --global user.signingkey <key-id>
git config --global commit.gpgsign true
# Sign commit
git commit -S -m "Signed commit message"
# Operating System
.DS_Store
Thumbs.db
# IDE/Editor
.vscode/
.idea/
*.swp
# Language-specific
__pycache__/
*.pyc
node_modules/
*.class
target/
# Build artifacts
dist/
build/
*.egg-info/
# Environment
.env
.env.local
venv/
env/
# Logs
*.log
logs/
# Temporary files
*.tmp
.cache/
** for recursive directory matching! to negate patterns (whitelist files)# for commentsgit check-ignore -v <file>.gitignore effectivelySearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer