पाठ 26 / 28

cherry-pick और bisect

git cherry-pick से एक commit copy करें और git bisect से वह commit खोजें जिसने bug पैदा किया।

cherry-pick

git cherry-pick किसी अन्य branch के एक commit को आपकी मौजूदा branch पर लगाता है, जैसे hotfix।

git switch release/1.2
git cherry-pick a1b2c3d     # copy one fix from main
git cherry-pick --abort      # if it conflicts and you want out

bisect

git bisect history में binary search करता है। एक bad और एक good commit चिह्नित करें, फिर Git के checkout किए हर कदम को test करें।

git bisect start
git bisect bad                 # current commit is broken
git bisect good v1.0.0         # this one worked
# test, then run: git bisect good  OR  git bisect bad
git bisect reset

Cherry-pick commit की प्रतिलिपि (नया hash) बनाता है, इसलिए संभव हो तो merge चुनें। Bisect git bisect run ./test.sh से अपने-आप भी चल सकता है।