Error/git-pull-conflict
Git Pull Divergent Branches Issue
/1 min readerrorgit
Error
Saat menjalankan git pull, muncul pesan berikut:
sh
- [ ] hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint: git config pull.rebase false # merge
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward onlyPenyebab
Branch lokal dan remote memiliki perubahan yang tidak sinkron, sehingga Git tidak bisa langsung melakukan merge otomatis.
Solusi
Pilih salah satu strategi berikut sesuai kebutuhan:
1️⃣ Merge (default behavior)
Jika ingin Git menggabungkan perubahan secara otomatis tanpa rebase:
sh
git config pull.rebase false
git pullAtau langsung:
sh
git pull --no-rebase2️⃣ Rebase (buat history lebih clean)
Jika ingin commit lokal di-reapply di atas perubahan terbaru dari remote:
sh
git config pull.rebase true
git pullAtau langsung:
sh
git pull --rebase3️⃣ Fast-forward only (tanpa merge commit)
Jika hanya ingin update branch lokal kalau bisa fast-forward:
sh
git config pull.ff only
git pullAtau langsung:
sh
git pull --ff-onlyTips Tambahan
Sebelum melakukan pull, cek status branch:
sh
git status
git log --oneline --graph --decorate --allJika ada perubahan lokal yang belum di-push, bisa disimpan dulu dengan stash:
sh
git stash
git pull --rebase
git stash pop # Balikin perubahan yang tadi di-stash