| name | git_workflow |
| description | Branch stratejisi, commit conventions, merge conflict çözümü ve Git best practices rehberi. |
🌿 Git Workflow
Branch stratejisi, commit conventions ve Git best practices rehberi.
📋 İçindekiler
- Branching Stratejileri
- Commit Conventions
- Merge vs Rebase
- Conflict Resolution
- Useful Commands
1. Branching Stratejileri
Git Flow
main (production)
└── develop
├── feature/user-auth
├── feature/payment
└── release/v1.2.0
└── hotfix/critical-bug
GitHub Flow (Önerilen - Basit)
main (always deployable)
├── feature/add-login
├── fix/button-style
└── chore/update-deps
Branch Naming
feature/user-authentication
feature/JIRA-123-add-payment
fix/login-redirect-issue
bugfix/memory-leak
hotfix/critical-security-patch
chore/update-dependencies
refactor/auth-module
docs/api-documentation
2. Commit Conventions
Conventional Commits
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types
| Type | Açıklama |
|---|
feat | Yeni özellik |
fix | Bug düzeltme |
docs | Dokümantasyon |
style | Formatting (kod değişikliği yok) |
refactor | Refactoring |
perf | Performans iyileştirme |
test | Test ekleme/düzeltme |
chore | Build, CI, dependencies |
ci | CI configuration |
revert | Revert commit |
Örnekler
feat(auth): add OAuth2 login support
fix(api): resolve null pointer in user endpoint
Closes
refactor!: drop support for Node 14
BREAKING CHANGE: Minimum Node version is now 18
chore(deps): update lodash to 4.17.21
Commit Message Rules
✅ DOĞRU:
- Imperative mood: "Add feature" (not "Added" or "Adds")
- 50 karakter başlık limiti
- Büyük harfle başla, nokta koyma
- Açıklayıcı body (neden, nasıl)
❌ YANLIŞ:
- "Fixed stuff"
- "WIP"
- "asdfasdf"
- "Updated code"
3. Merge vs Rebase
Merge
git checkout main
git merge feature/user-auth
Rebase
git checkout feature/user-auth
git rebase main
Ne Zaman Hangisi?
| Durum | Strateji |
|---|
| Public/shared branch | Merge |
| Local feature branch | Rebase |
| Main'e feature merge | Squash merge |
| Hotfix | Merge |
Squash Merge
git checkout main
git merge --squash feature/user-auth
git commit -m "feat(auth): add user authentication"
4. Conflict Resolution
Conflict Markers
<<<<<<< HEAD
Current branch content
=======
Incoming branch content
>>>>>>> feature-branch
Resolution Steps
git status
git add <resolved-file>
git merge --continue
git rebase --continue
VS Code ile
Abort
git merge --abort
git rebase --abort
5. Useful Commands
History
git log --oneline --graph --all
git log -10 --oneline
git log --follow -p -- path/to/file
Undo
git reset --soft HEAD~1
git reset --hard HEAD~1
git revert <commit-hash>
git restore --staged <file>
git restore <file>
Stash
git stash
git stash push -m "WIP: feature X"
git stash list
git stash pop
git stash apply stash@{2}
Interactive Rebase
git rebase -i HEAD~3
pick abc1234 First commit
squash def5678 Second commit
reword ghi9012 Third commit
Cherry Pick
git cherry-pick <commit-hash>
git cherry-pick <hash1> <hash2>
Git Workflow v1.1 - Enhanced
🔄 Workflow
Kaynak: Atlassian Git Workflows & Trunk Based Development
Aşama 1: Branching
Aşama 2: Committing
Aşama 3: Merging
Kontrol Noktaları
| Aşama | Doğrulama |
|---|
| 1 | Main branch her an deploy edilebilir (Green) durumda mı? |
| 2 | git log --oneline okunduğunda bir hikaye anlatıyor mu? |
| 3 | Conflict çözülürken kod kaybı yaşanma riski var mı? |