GitHub Best Practices Guide
Branch Naming Conventions
Branch Type |
Naming Convention |
Example |
Feature |
feature/<name> |
feature/auth-ui |
Bugfix |
fix/<name> |
fix/input-validation |
Hotfix |
hotfix/<name> |
hotfix/payment-crash |
Enhancement |
enhancement/<name> |
enhancement/performance-boost |
Release |
release/<version> |
release/v1.2.0 |
Experiment |
experiment/<name> |
experiment/new-login-flow |
Documentation |
docs/<name> |
docs/api-reference |
Commit Message Structure
Type |
Emoji |
Prefix |
Example |
Feature |
✨ |
feat: |
✨ feat(auth): add password reset page |
Bugfix |
🐛 |
fix: |
🐛 fix(ui): resolve input field validation issue |
Refactor |
♻️ |
refactor: |
♻️ refactor(signup): optimize form state handling |
Performance |
⚡ |
perf: |
⚡ perf(api): reduce database query time |
Style |
💄 |
style: |
💄 style(button): improve hover effect |
Documentation |
📝 |
docs: |
📝 docs(readme): update installation steps |
Common Git Commands
Cloning a Repository
git clone <repo-url>
Creating a New Branch
git checkout -b feature/new-feature
Switching Branches
git checkout main
Staging and Committing Changes
git add .
git commit -m "✨ feat(ui): add new login page"
Pushing Changes
git push origin feature/new-feature
Fetching and Merging Updates
git fetch origin
git merge origin/main
Rebasing a Branch
git rebase main
Undoing the Last Commit
git reset --soft HEAD~1 # Keep changes
git reset --hard HEAD~1 # Remove changes
Releases and Tags
Creating a Tag for a Release
git tag -a v1.0.0 -m "Release version 1.0.0"
Pushing Tags to Remote
git push origin v1.0.0
Listing All Tags
git tag
Creating a GitHub Release
- Go to the repository on GitHub.
- Navigate to the Releases section.
- Click Draft a new release.
- Select the tag and add release notes.
- Click Publish Release.
General Best Practices
- Keep branch names short but descriptive.
- Use lowercase and hyphens (-) for branch names.
- Follow conventional commits format for commit messages.
-
Use imperative mood (e.g., "Add login button" instead of "Added login
button").
- Always fetch and merge before pushing changes.
- Use feature branches for new development.
- Tag releases properly and document major changes.