আপনার পছন্দসই ফলাফল কী তা সম্পূর্ণরূপে পরিষ্কার নয়, সুতরাং উত্তর এবং তাদের মন্তব্যে এটি করার "সঠিক" উপায় সম্পর্কে কিছুটা বিভ্রান্তি রয়েছে। আমি একটি ওভারভিউ দেওয়ার চেষ্টা করি এবং নিম্নলিখিত তিনটি বিকল্প দেখতে পারি:
সংঘাতের জন্য মার্জ এবং বি ব্যবহার করে দেখুন
এই না "জন্য তাহাদেরই সংস্করণ git merge -s ours
কিন্তু" "এর জন্য তাহাদেরই সংস্করণ git merge -X ours
" (যার জন্য ছোট git merge -s recursive -X ours
):
git checkout branchA
# also uses -s recursive implicitly
git merge -X theirs branchB
উদাহরণস্বরূপ অ্যালান ডাব্লু স্মিথের উত্তর এটি করে।
কেবল বি থেকে সামগ্রী ব্যবহার করুন
এই সৃষ্টি মার্জ উভয় শাখার জন্য কমিট কিন্তু থেকে সমস্ত পরিবর্তন বাতিল branchA
এবং একমাত্র সামগ্রী রাখে branchB
।
# Get the content you want to keep.
# If you want to keep branchB at the current commit, you can add --detached,
# else it will be advanced to the merge commit in the next step.
git checkout branchB
# Do the merge an keep current (our) content from branchB we just checked out.
git merge -s ours branchA
# Set branchA to current commit and check it out.
git checkout -B branchA
মনে রাখবেন যে মার্জটি এখন প্রথম পিতামাতার সাথে চুক্তি করে তা হ'ল branchB
কেবলমাত্র দ্বিতীয়টি এসেছে branchA
। উদাহরণস্বরূপ, গ্যান্ডালফ 458 এর উত্তর এটি করে।
কেবল বি থেকে সামগ্রী ব্যবহার করুন এবং সঠিক পিতামাতার ক্রম রাখুন
এটি আসল "এর জন্য তাদের সংস্করণ git merge -s ours
"। এটিতে বিকল্পটির মতো একই বিষয়বস্তু রয়েছে (যেমন কেবলমাত্র এটি থেকে branchB
) তবে পিতামাতার ক্রমটি সঠিক, অর্থাত প্রথম পিতা-মাতার কাছ থেকে আসে branchA
এবং দ্বিতীয়টি আসে branchB
।
git checkout branchA
# Do a merge commit. The content of this commit does not matter,
# so use a strategy that never fails.
# Note: This advances branchA.
git merge -s ours branchB
# Change working tree and index to desired content.
# --detach ensures branchB will not move when doing the reset in the next step.
git checkout --detach branchB
# Move HEAD to branchA without changing contents of working tree and index.
git reset --soft branchA
# 'attach' HEAD to branchA.
# This ensures branchA will move when doing 'commit --amend'.
git checkout branchA
# Change content of merge commit to current index (i.e. content of branchB).
git commit --amend -C HEAD
এই কি পল Pladijs এর উত্তর (ক অস্থায়ী শাখা প্রয়োজন ছাড়া) করে।