ARAÇLAR12m READ18 Haziran 2026

Git ve GitHub Kullanımı: Başlangıçtan Branch Yönetimine

Commit, branch, merge, rebase, conflict çözme ve GitHub PR iş akışı Türkçe anlatım.

Git, kod değişikliklerini takip eden dağıtık versiyon kontrol sistemidir. GitHub ise Git repository'lerini bulutta barındıran platform. Bu makale; ilk commit'ten başlayarak branch yönetimi, merge stratejileri ve GitHub PR sürecine kadar tüm temel Git iş akışını anlatıyor.

Git'i Anlama: Üç Alan

// PLAINTEXT //
Working Directory    Staging Area       Repository (.git)
━━━━━━━━━━━━━━━    ━━━━━━━━━━━━━    ━━━━━━━━━━━━━━━━━
Dosyaları düzenle   git add          git commit
                    ←────────────    git restore

Git üç alanda çalışır. Değişiklikleri önce Staging'e ekler (git add), sonra commit'le kalıcı yapar.

Kurulum ve Yapılandırma

// BASH //
# Kullanıcı bilgileri — her commit'e eklenir
git config --global user.name "Adem Yılmaz"
git config --global user.email "adem@example.com"
 
# Varsayılan branch adı
git config --global init.defaultBranch main
 
# VS Code'u varsayılan editor yap
git config --global core.editor "code --wait"
 
# Güzel diff görünümü
git config --global core.pager "less -FRX"
 
# Ayarları kontrol et
git config --global --list

Temel İş Akışı

// BASH //
# Yeni repo başlat
git init my-project
cd my-project
 
# veya GitHub'dan kopyala
git clone https://github.com/kullanici/repo.git
 
# Durum kontrolü — her zaman buradan başla
git status
 
# Değişiklikleri aşamalandır
git add app.ts              # tek dosya
git add src/                # klasör
git add -p                  # interaktif — parça parça seç
 
# Commit oluştur
git commit -m "feat: kullanıcı giriş formu eklendi"
 
# Geçmişi görüntüle
git log --oneline --graph --decorate

.gitignore: Ne Takip Edilmeyecek

// GITIGNORE //
# Node.js
node_modules/
dist/
.env
.env.local
.env.*.local
 
# Python
__pycache__/
*.pyc
.venv/
*.egg-info/
 
# Genel
.DS_Store
Thumbs.db
*.log
.idea/
.vscode/settings.json
 
# Build çıktıları
build/
out/
coverage/

Branch: Paralel Geliştirme

// BASH //
# Tüm branch'leri listele
git branch -a
 
# Yeni branch oluştur ve geç
git checkout -b feature/kullanici-profil
# veya modern syntax:
git switch -c feature/kullanici-profil
 
# Branch'ler arası geçiş
git switch main
git switch feature/kullanici-profil
 
# Branch'i sil (merge sonrası)
git branch -d feature/kullanici-profil   # güvenli sil
git branch -D feature/kullanici-profil   # zorla sil

Merge vs Rebase

// BASH //
# Merge — commit geçmişini korur, merge commit oluşturur
git switch main
git merge feature/kullanici-profil
# Sonuç: merge commit + tüm feature commit'leri
 
# Rebase — feature commit'lerini main'in üstüne yeniden yazar
git switch feature/kullanici-profil
git rebase main
# Sonuç: temiz, doğrusal geçmiş
 
# Squash merge — tüm feature'ı tek commit'e sıkıştır
git merge --squash feature/kullanici-profil
git commit -m "feat: kullanıcı profil sayfası"

Genel kural: Paylaşılan branch'lerde (main, develop) rebase kullanma — geçmişi yeniden yazar ve takım arkadaşlarını etkiler.

Conflict Çözme

// BASH //
git merge feature/login
# CONFLICT (content): Merge conflict in src/auth.ts
# Automatic merge failed; fix conflicts and then commit the result.
// TYPESCRIPT //
// Çakışan dosya görünümü:
<<<<<<< HEAD (main branch'teki versiyon)
function login(email: string, password: string) {
  return authenticate(email, password);
}
=======
async function login(email: string, password: string) {
  return await authenticateAsync(email, password);
}
>>>>>>> feature/login (gelen versiyon)
 
// Çakışmayı çöz — doğru versiyonu seç veya birleştir:
async function login(email: string, password: string) {
  return await authenticateAsync(email, password);
}
// BASH //
# Çakışmayı çözdükten sonra
git add src/auth.ts
git commit -m "merge: login async versiyonu birleştirildi"

GitHub: Remote İş Akışı

// BASH //
# Remote ekle
git remote add origin https://github.com/kullanici/codeforge.git
 
# İlk push (upstream set)
git push -u origin main
 
# Sonraki push'lar
git push
 
# Remote'dan güncelle
git fetch origin          # indir ama merge etme
git pull                  # fetch + merge
git pull --rebase         # fetch + rebase (tercih edilir)
 
# Branch'i remote'a push et
git push origin feature/yeni-ozellik

Commit Mesajı: Conventional Commits

// BASH //
# Format: <type>(<scope>): <description>
feat(auth): JWT refresh token mekanizması eklendi
fix(db): PostgreSQL bağlantı havuzu sızıntısı giderildi
docs(api): endpoint dokümantasyonu güncellendi
chore(deps): Next.js 15.2.0'a yükseltildi
refactor(posts): repository katmanı ayrıştırıldı
test(auth): login controller unit testleri eklendi
style: Prettier formatlaması uygulandı
perf(queries): N+1 sorgu eager loading ile optimize edildi
 
# Türkçe commit mesajı da kabul edilir
git commit -m "feat(ders): Python async dersi eklendi"

Stash: Geçici Değişiklik Saklama

// BASH //
# Yarım kalan değişikliği sakla
git stash push -m "login formu - yarım kaldı"
 
# Başka bir branch'e geç, orada çalış...
 
# Geri dön ve değişikliği geri getir
git stash pop              # son stash'ı uygula + sil
git stash apply stash@{0} # uygula ama listede bırak
 
# Stash listesi
git stash list

Git Log: Geçmişi Keşfet

// BASH //
# Güzel grafik görünümü
git log --oneline --graph --decorate --all
 
# Belirli bir dosyanın geçmişi
git log --follow -p src/auth/login.ts
 
# Belirli bir geliştirici
git log --author="Adem" --since="2 weeks ago"
 
# Belirli bir ifade içeren commit'ler
git log --grep="fix" --oneline
 
# İki commit arasındaki değişiklikler
git diff v1.0.0..v1.1.0 -- src/
 
# Dosyayı kimin yazdığını bul
git blame src/lib/jwt.ts

GitHub Pull Request İş Akışı

// BASH //
# 1. Feature branch oluştur
git switch -c feature/dark-mode
 
# 2. Geliştir, commit et
git add .
git commit -m "feat(ui): dark mode toggle eklendi"
 
# 3. Remote'a push et
git push origin feature/dark-mode
 
# 4. GitHub'da PR aç (veya gh CLI)
gh pr create --title "Dark mode desteği" \
             --body "Sistem tercihi ve manuel toggle desteklendi"
 
# 5. Review sonrası main'e merge
# GitHub'dan yapılır (Squash merge önerilir)
 
# 6. Local'i temizle
git switch main
git pull
git branch -d feature/dark-mode

Özet

Git'in temeli üç alandan geçer: working directory → git add → staging → git commit → repository. Branch oluştur, feature geliştir, main'e merge et veya rebase yap. Conflict çıkınca dosyayı düzenle, git add yap, commit et. GitHub PR'ı merge edilince local branch'i sil, main'i pull et. Conventional Commits formatı ekiple çalışmayı kolaylaştırır.