BM: Baca dalam Bahasa Melayu
World 3: Parallel Universes
Fix conflicts in VS Code
You will learn: to fix a conflict, finish the merge, or cancel it safely.
The problem
Your merge with cake stopped on a conflict. Time to fix it. Calmly, in three small steps.
Watch
Tap the glowing dots to explore.
0 of 5 explored
Open the file in VS Code. It paints each side and puts buttons above the clash. Tap the dots.
Try it
Your diary had both on day 2! Keep both lines. Then finish the merge.
Pick what stays in each conflict. Then finish.
Conflicts left: 1 of 1
index.htmlboth modified
<h1>My Diary</h1> <p>Day 1: I learned Git.</p>
<<<<<<< HEAD (conflict marker)<p>Day 2: I learned branches.</p>======= (conflict marker)<p>Day 2: I baked a cake.</p>>>>>>>> cake (conflict marker)Hint
Tap “Accept Both Changes”. Then the finish button.Watch
git add index.html tells Git: this file is fixed. Then git commit makes the merge commit. The + and Commit buttons in VS Code do the same.
Try it
Not ready to choose? Cancel the merge. Everything goes back to before.
Hint
Typegit merge --abort, then press Enter.Predict
You fixed the file but forgot git add. You run git commit. What happens?
Pick one answer.
Check
Put the conflict fix in order.
First step at the top. Put these in order. Use the arrows, or drag.
- git commit to finish the merge
- Open the file with the conflict
- Pick what stays and delete the markers
- git add the file
You did it!
You can now fix a merge conflict, or cancel it safely.
Go deeper (optional)
VS Code’s Merge Editor shows yours, theirs and the result together. From the terminal, git mergetool opens a merge tool you set up. git merge --abort works until you commit the merge. After that, undo it like any commit.
Bahasa Melayu
Merge anda dengan cake berhenti kerana konflik. Masa untuk baiki. Dengan tenang, dalam tiga langkah kecil.
Buka fail dalam VS Code. Ia warnakan setiap pihak dan letak butang di atas pertembungan. Ketik titik-titik itu.
Diari anda ada kedua-duanya pada hari 2! Kekalkan kedua-dua baris. Kemudian habiskan merge.
git add index.html beritahu Git: fail ini dah dibaiki. Kemudian git commit buat merge commit. Butang + dan Commit dalam VS Code buat benda sama.
Belum sedia nak pilih? Batalkan merge. Semuanya kembali macam sebelum.
git merge --abort, kemudian tekan Enter.Anda dah baiki fail tapi lupa git add. Anda jalankan git commit. Apa jadi?
Susun langkah membaiki konflik.
Kini anda boleh baiki konflik merge, atau batalkannya dengan selamat.
You finished this before. Practice is always welcome!
Official docs: git merge (--abort) · Merge conflicts in VS Code
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?