একটা merge conflict ঘটে যখন Git স্বয়ংক্রিয়ভাবে দুটো পরিবর্তন একসাথে করতে পারে না — সাধারণত কারণ দুটো branch-ই ঠিক একই লাইন ভিন্নভাবে edit করেছে। এটা ভয় পাওয়ার মতো একটা error না; এটা Git সঠিকভাবে অনুমান করতে অস্বীকার করছে।
git merge feature-login
# Auto-merging index.html
# CONFLICT (content): Merge conflict in index.html
# Automatic merge failed; fix conflicts and then commit the result.Git সরাসরি conflict-এ থাকা file edit করে, দুটো version চিহ্নিত করে।
<h1>Welcome</h1>
<<<<<<< HEAD
<p>This is the main branch version.</p>
=======
<p>This is the feature-login branch version.</p>
>>>>>>> feature-login| Marker | মানে |
|---|---|
| <<<<<<< HEAD | বর্তমান branch-এর version-এর শুরু |
| ======= | দুটো version-এর মধ্যে বিভাজক |
| >>>>>>> feature-login | আসা branch-এর version-এর শেষ, এর নাম দিয়ে |
হাতে file edit করুন — একটা version রাখুন, অন্যটা রাখুন, বা দুটো মিলিয়ে কিছু লিখুন — আর প্রতিটা marker লাইন সম্পূর্ণভাবে সরান।
<h1>Welcome</h1>
<p>This is the main branch version.</p>git add index.html
git commit
# Git একটা merge commit message আগে থেকে পূরণ করে — সাধারণত যেমন আছে তেমন accept করা ঠিক# এখনো সমাধান দরকার এমন প্রতিটা file দেখুন
git status
# Both modified: index.html
# Both modified: style.cssএকটা merge মাঝপথে খারাপভাবে ভুল হয়ে গেলে, এটা সম্পূর্ণভাবে ছেড়ে দেওয়া যায়, এটা শুরু হওয়ার ঠিক আগের অবস্থায় ফিরে গিয়ে।
git merge --abortবাস্তবে এগুলো সমাধানের একটা দ্রুত উপায়
বেশিরভাগ code editor (তাদের মধ্যে VS Code) click-করা-যায় "Accept Current," "Accept Incoming," আর "Accept Both" button সহ conflict marker দেখায় — conflict নিয়মিত ঘটতে শুরু করলে হাতে marker edit করার বদলে সত্যিকারভাবে ব্যবহারের যোগ্য।