Git, kaynak kodundaki değişiklikleri zaman içinde takip eden dağıtık bir sürüm kontrol sistemidir.
# Kullanıcı adını ayarla
git config --global user.name "Adınız"
# E-postayı ayarla
git config --global user.email "email@example.com"
# Proje klasörü oluştur
mkdir my-project
cd my-project
# Git deposunu başlat
git init
# Dosya oluştur
echo "# Benim Projem" > README.md
# Ekle ve commit
git add README.md
git commit -m "İlk commit"
# gityar'dan
git clone http://localhost:3000/username/repo.git
# SSH ile
git clone git@localhost:username/repo.git
git status
# Belirli dosya ekle
git add filename.txt
# Tüm değişiklikleri ekle
git add .
# Tüm .txt dosyalarını ekle
git add *.txt
# Mesaj ile commit
git commit -m "Açıklayıcı mesaj"
# Değiştirilen tüm dosyaları commit et
git commit -a -m "Dosyaları güncelle"
# main branch'ine push
git push origin main
# Yeni branch push
git push -u feature-branch
# Değişiklikleri getir ve birleştir
git pull origin main
# Yeni branch oluştur
git checkout -b feature/yeni-ozellik
# Branch değiştir
git checkout main
# Branch'leri listele
git branch
# Yerel branch sil
git branch -d feature-branch
# Remote branch sil
git push origin --delete feature-branch
# Hedef branch'e geç
git checkout main
# Diğer branch'i merge et
git merge feature-branch
# Branch'inizi main üzerine rebase et
git checkout feature-branch
git rebase main
Çakışma olduğunda:
# Çakışan dosyaları gör
git status
# Dosyaları düzenle ve çakışmaları çöz
# Sonra:
git add .
git commit -m "Çakışmaları çöz"
# Dosyadaki değişiklikleri iptal et
git checkout -- filename.txt
# Dosyayı staged durumundan çıkar
git reset HEAD filename.txt
# Son commit mesajını değiştir
git commit --amend -m "Yeni mesaj"
# Önceki commit'e geri dön (hard)
git reset --hard HEAD~1
# Soft geri dön (değişiklikler kalır)
git reset --soft HEAD~1
# Hafif etiket
git tag v1.0.0
# Mesajlı etiket
git tag -a v1.0.0 -m "Sürüm 1.0.0"
# Etiketleri push et
git push origin --tags