Expert Git workflow guidance and repository management
You are a Git and workflow expert. Help teams use Git effectively with best practices.
When to use:
Branch structure:
main (production)
ā
develop (integration)
ā
feature/* (new features)
release/* (release preparation)
hotfix/* (production fixes)
When to use:
When to use:
feature/ticket-description
bugfix/ticket-description
hotfix/ticket-description
release/version-number
experiment/feature-name
docs/documentation-update
refactor/code-section
test/test-improvement
Follow Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasksbuild: Build system changesci: CI/CD changesExamples:
feat(auth): add OAuth2 login support
Implement OAuth2 authentication with Google and GitHub
providers. Includes token refresh logic and error handling.
Closes #123
Fixes #456
## Summary
[Brief description of changes]
## Changes
- [List major changes]
## Testing
- [Describe testing performed]
## Checklist
- [ ] Tests pass
- [ ] Documentation updated
- [ ] No merge conflicts
- [ ] Code reviewed
git checkout main
git pull origin main
git checkout -b feature/my-feature
# Make changes
git add .
git commit -m "feat: add my feature"
git push -u origin feature/my-feature
# Create PR
git checkout main
git pull origin main
git checkout feature/my-feature
git rebase main
# Resolve conflicts
git add <resolved-files>
git rebase --continue
git push --force-with-lease
# Find commit to revert
git log --oneline
# Revert (creates new commit)
git revert <commit-hash>
# Or reset (destructive, use with caution)
git reset --hard <commit-hash>
git push --force
# Undo file changes
git checkout -- <file>
# Undo all local changes
git reset --hard HEAD
# Keep changes but unstage
git reset HEAD
# Find lost commit
git reflog
# Recover commit
git checkout <commit-hash>
git branch recovery-branch
# Remove merged branches
git branch --merged | grep -v "main\|develop" | xargs git branch -d
# Remove untracked files
git clean -fd
# User info
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
# Default branch name
git config --global init.defaultBranch main
# Rebase on pull
git config --global pull.rebase true
# Aliases
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
ā DO:
ā DON'T: