Чіткі та структуровані commit messages допомагають:
- 📖 Розуміти історію змін
- 🔍 Знаходити конкретні зміни
- 📝 Генерувати CHANGELOG автоматично
- 🔄 Робити revert безпечно
<type>(<scope>): <subject>
<body>
<footer>
feat(auth): add JWT authentication
Implement JWT-based authentication system with refresh tokens.
Uses HS256 algorithm with secret from environment variables.
Closes #123
Тип commit вказує на характер змін:
- feat — нова функціональність
- fix — виправлення bug
- docs — зміни в документації
- style — форматування, missing semi colons, etc (не впливає на код)
- refactor — рефакторинг коду (без нової функціональності або fixes)
- perf — покращення performance
- test — додавання або виправлення tests
- build — зміни в build system або external dependencies
- ci — зміни в CI конфігурації та scripts
- chore — інші зміни що не модифікують src або test files
- revert — revert попереднього commit
feat: add user authentication
fix: correct validation error in login form
docs: update API documentation
style: format code with prettier
refactor: extract validation logic to separate module
perf: optimize database queries
test: add unit tests for auth service
build: update webpack configuration
ci: add codecov integration
chore: update dependencies
revert: revert "feat: add user authentication"Scope вказує на частину проєкту що змінюється:
Приклади scope:
auth— authentication/authorizationapi— API endpointsdb— databaseui— user interfaceconfig— configurationdeps— dependencies
feat(auth): add password reset
fix(api): handle null response
docs(readme): update installation stepsМожна пропустити якщо зміни стосуються всього проєкту:
docs: update contributing guidelines
chore: update all dependenciesКоротке описання зміни:
- Imperative mood — "add" не "added" чи "adds"
- No capitalization — lowercase first letter
- No period — без крапки в кінці
- Max 50 characters — коротко та ясно
add user authentication
fix memory leak in cache
update installation docs
remove deprecated API
Added user authentication ❌ (past tense)
Fix Memory Leak ❌ (capitalized)
update docs. ❌ (period at end)
This commit updates the documentation for the new API endpoints ❌ (too long)
Детальний опис змін:
- Складні зміни що потребують пояснення
- Breaking changes
- Архітектурні рішення
- Технічні деталі
- Відокремлений пустим рядком від subject
- Wrap at 72 characters для читабельності
- Пояснює "що" та "чому", не "як"
- Може містити декілька параграфів
feat(auth): implement OAuth2 flow
Add OAuth2 authentication with support for Google and GitHub
providers. Users can now login using their social accounts.
This change improves user experience by reducing friction during
signup process. Implementation follows OAuth2 RFC 6749 standard.
Technical details:
- Using passport.js for OAuth strategies
- Tokens stored in secure HTTP-only cookies
- Added refresh token rotation for security
Metadata про commit:
Для breaking changes використовуйте BREAKING CHANGE::
feat(api): change authentication endpoint
BREAKING CHANGE: Authentication endpoint moved from /auth to /api/v2/auth.
All clients must update their API calls.
Migration guide:
- Update API_URL from `/auth` to `/api/v2/auth`
- Add API version header: `X-API-Version: 2`
Link до issues або PR:
fix(api): handle timeout errors
Properly handle timeout errors and return 408 status code.
Fixes #123
Closes #456
Related to #789
Keywords:
Fixes #123— closes issue automaticallyCloses #123— closes issue automaticallyResolves #123— closes issue automaticallyRelated to #123— створює reference (не закриває)
revert: feat(auth): add JWT authentication
This reverts commit 1234567890abcdef.
Reason: JWT implementation caused performance issues in production.
GitHub автоматично створює merge commits. Якщо робите manual merge:
Merge branch 'feature/user-auth' into main
Merged PR #123: Add user authentication
Не робіть це — розділіть на кілька commits:
❌ feat: add login, fix logout, update docs
Робіть окремі commits:
✅ feat(auth): add login functionality
✅ fix(auth): correct logout redirect
✅ docs(auth): update authentication guide
# Створення нової функціональності
git commit -m "feat(user): add user profile page"
git commit -m "test(user): add tests for profile page"
git commit -m "docs(user): document profile page API"# Simple bug fix
git commit -m "fix(api): handle null user response"
# Complex bug fix з body
git commit -m "fix(api): prevent race condition in user creation
Add mutex lock to prevent concurrent user creation with same email.
This fixes intermittent duplicate user errors in production.
Fixes #456"git commit -m "refactor(auth): extract validation logic
Move validation from controller to separate validator class.
Improves testability and code organization."git commit -m "docs(readme): update installation instructions"
git commit -m "docs(api): add examples for authentication endpoints"- ✅ Після завершення логічної зміни
- ✅ Коли код компілюється і tests проходять
- ✅ Перед переключенням на іншу задачу
- ✅ В кінці робочого дня (WIP commits)
Кожен commit повинен бути atomic — одна логічна зміна:
# ✅ GOOD - atomic commits
git commit -m "feat(auth): add login form"
git commit -m "feat(auth): add login API endpoint"
git commit -m "test(auth): add login tests"
# ❌ BAD - non-atomic
git commit -m "add complete authentication system with tests and docs"Для незавершеної роботи:
# Save work in progress
git commit -m "wip: implement user profile (incomplete)"
# Continue next day
# ...make changes...
# Squash WIP commits before PR
git rebase -i HEAD~3
# Squash WIP commits into meaningful commitАвтоматично перевіряє commit message:
# Install commitlint
npm install --save-dev @commitlint/{cli,config-conventional}
# Configure
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
# Setup hook
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'# .husky/pre-commit
npm run lint
npm testInteractive tool для створення commits:
# Install
npm install -g commitizen cz-conventional-changelog
# Use
git czOutput:
? Select the type of change: (Use arrow keys)
❯ feat: A new feature
fix: A bug fix
docs: Documentation only changes
style: Changes that don't affect code meaning
refactor: A code change that neither fixes a bug nor adds a feature
perf: A code change that improves performance
test: Adding missing tests
Автоматична генерація CHANGELOG:
npm install -g conventional-changelog-cli
conventional-changelog -p angular -i CHANGELOG.md -s# Readable log
git log --oneline --graph --decorate
# Filter by type
git log --oneline --grep="^feat"
git log --oneline --grep="^fix"
# Show commits for specific file
git log --oneline -- path/to/file
# Show commits by author
git log --author="username"# Find when bug was introduced
git log --grep="fix.*login"
# Find all breaking changes
git log --grep="BREAKING CHANGE"
# Find commits affecting specific feature
git log --grep="feat.*auth"# Change last commit message
git commit --amend -m "fix(auth): correct typo in validation"
# Add forgotten files to last commit
git add forgotten-file.js
git commit --amend --no-edit# Edit last 3 commits
git rebase -i HEAD~3
# Options:
# pick = keep commit
# reword = keep commit but edit message
# edit = pause to amend commit
# squash = merge into previous commit
# fixup = like squash but discard message
# drop = remove commitВажливо: Не rebase commits що вже в main або shared branch!
- ✅ Write clear, concise messages
- ✅ Use conventional format
- ✅ Reference issues
- ✅ Explain "why" not "what"
- ✅ Make atomic commits
- ✅ Test before commit
- ✅ Proofread messages
- ❌ Vague messages ("fix bug", "update code")
- ❌ Too long subject lines
- ❌ Mix multiple changes
- ❌ Commit broken code
- ❌ Commit secrets or credentials
- ❌ Use past tense
- ❌ Skip type prefix
feat(search): add fuzzy search capability
feat(ui): implement dark mode
feat(api): add pagination to user list
feat(export): support CSV export
fix(login): prevent double form submission
fix(api): handle timeout gracefully
fix(ui): correct button alignment on mobile
fix(validation): accept international phone numbers
docs(readme): add quick start guide
docs(api): document error responses
docs(contributing): update PR process
docs(changelog): add version 2.0.0 notes
perf(db): optimize user query with indexes
perf(api): add caching layer
perf(ui): lazy load images
test(auth): add integration tests
test(api): increase coverage to 90%
test(ui): add e2e tests for checkout
# Change last commit message
git commit --amend
# Change older commit
git rebase -i HEAD~5 # go back 5 commits
# Change 'pick' to 'reword' for commits to edit# Move last commit to another branch
git checkout correct-branch
git cherry-pick wrong-branch
git checkout wrong-branch
git reset --hard HEAD~1Створіть issue з label "documentation" якщо щось незрозуміло.