Git komutları hızlı referans
Git, dosya değişikliklerinizi bir depodaki bir dizi commit olarak izler. Bu komutlar günlük akışı kapsar: depo başlatma, çalışmayı kaydetme, dallanma, birleştirme ve uzakla paylaşma. Öğrenirken bu sayfayı açık tutun.
| Komut | Ne yapar |
|---|---|
| git init | Create a new, empty Git repository in the current directory. |
| git clone | Download a remote repository and its full history to your machine. |
| git status | Show changed, staged and untracked files in the working tree. |
| git add | Stage changes (files) to be included in the next commit. |
| git commit | Record staged changes as a new commit with a message. |
| git log | Display the commit history of the repository. |
| git diff | Show unstaged or staged differences between states. |
| git branch | List, create or delete branches in the repository. |
| git checkout / switch | Switch branches or restore files (switch is the modern command). |
| git merge | Join another branch's history into the current branch. |
| git rebase | Reapply commits on top of another base commit, rewriting history. |
| git pull | Fetch from a remote and merge the changes into the current branch. |
| git push | Upload local commits to a remote repository. |
| git stash | Temporarily shelve uncommitted changes to reapply later. |
| git remote | Manage the set of remote repositories you track. |
Notlar
- Çoğu komut bayrak kabul eder (örneğin -m mesaj için, -a hepsi için); tam liste için 'git help <komut>' çalıştırın.
- Dal adları ucuz ve atılabilirdir — özellik dalında sık sık commit yapın, sonra main'e birleştirin.
- rebase veya reset gibi yıkıcı komutlardan önce çalışmanızın commit'lendiğinden veya stash'lendiğinden emin olun.
Sık sorulan sorular
- merge ve rebase arasındaki fark nedir?
- Merge, iki ebeveyni olan yeni bir commit ile geçmişleri birleştirir. Rebase ise commit'lerinizi başka bir dalın üzerine yeniden oynatır; doğrusal bir geçmiş oluşturur ama commit ID'lerini yeniden yazar.
- Bir commit'i nasıl geri alırım?
- Değişikliği geri alan yeni bir commit eklemek için 'git revert <commit>' kullanın (güvenli, paylaşılan geçmiş korunur). 'git reset' geçmişi yeniden yazar ve paylaşılan dallarda kullanılmamalıdır.
- git pull ve git fetch arasındaki fark nedir?
- Fetch, çalışma ağacınıza dokunmadan uzaktan commit ve referansları indirir. Pull, fetch yapar ve ardından bu değişiklikleri geçerli dalınıza merge veya rebase eder.
- git stash ne zaman kullanılır?
- Stash, commit edilmemiş değişiklikleri geçici olarak rafa kaldırır; böylece dal değiştirebilir veya temiz bir pull yapabilir, sonra 'git stash pop' ile geri getirebilirsiniz.