BM: Baca dalam Bahasa Melayu
World 5: Teamwork
Conflicts in a PR
You will learn: why a pull request gets a conflict, and how to fix it.
The problem
You and Ravi both changed the README’s second line. His PR merged first. Now your PR says it has a conflict: Two changes hit the same spot. You pick what stays.. Did you break something?
Pick one answer.
Try it
Git marks the clash with conflict markers: The lines <<<<<<<, ======= and >>>>>>> that Git puts around a clash.. Your line sits on top. Main’s line sits below. Tap the three marker lines.
Tap every marker line.
0 of 3 found
Try it
Now fix it. Keep the words you want. Delete all three marker lines.
No markers left, and at least one line about Friday.
Preview
Club Site
<<<<<<< my-tagline Code, snacks and friends. Every Friday!
We meet every Friday after school.
main
1 of 2 goals done
Hint
You can keep one line, or both. Just remove the three marker lines.Predict
GitHub’s web editor fixes simple line clashes. Here, main deleted a file that your branch changed. Can the web editor fix that?
Pick one answer.
Check
Put the steps to fix a conflict on GitHub in order. First at the top.
First step at the top. Put these in order. Use the arrows, or drag.
- Open the conflict from the PR
- Delete the conflict markers
- Commit the merge
- Pick the words to keep
- Mark the file as resolved
Check
Fewer conflicts next time. Good habit, or needs work?
Swipe right for good, left for needs work. Or use the buttons.
Keep PRs small and merge them soon
You did it!
You can now fix a conflict in a pull request without panic.
Go deeper (optional)
On GitHub, fixing a conflict makes a merge commit. It merges main into your PR branch. Not just the clashing lines: all of main comes in. On your computer, switch to your branch and merge main into it. Fix the files, then git add and git commit. Push, and the PR updates. World 3 shows merging in detail.
Bahasa Melayu
Anda dan Ravi sama-sama ubah baris kedua README. PR dia di-merge (dicantum) dulu. Sekarang PR anda kata ada konflik. Anda dah rosakkan sesuatu ke?
Git tandakan pertembungan dengan penanda konflik. Baris anda di atas. Baris main di bawah. Tekan tiga baris penanda itu.
Sekarang baiki. Simpan perkataan yang anda mahu. Padam ketiga-tiga baris penanda.
Editor web GitHub boleh baiki pertembungan baris yang mudah. Di sini, main padam satu fail yang branch (cabang) anda ubah. Bolehkah editor web baiki itu?
Susun langkah membaiki konflik di GitHub. Yang pertama di atas.
Kurangkan konflik lain kali. Tabiat bagus, atau perlu baiki?
Kini anda boleh baiki konflik dalam pull request tanpa panik.
You finished this before. Practice is always welcome!
Official docs: About merge conflicts · Resolving a merge conflict on GitHub · git merge (conflicts)
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?