Git ขั้นสูง
Amanda Crawford-Adamo
Software and Data Engineer
เครื่องมือที่ใช้ binary search เพื่อค้นหา commit ที่ทำให้เกิดบัก
คำสั่ง Git Bisect
git bisect
จุดประสงค์
เริ่ม session ของ git bisect
git bisect start
กำหนดสถานะปัจจุบันเป็น bad state
git bisect bad
ระบุ good state ล่าสุดที่รู้จัก
git bisect good <commit-hash>

ทำเครื่องหมาย commit ว่าเป็น bad commit
git bisect bad
ทำเครื่องหมาย commit ว่าเป็น good commit
git bisect good

ตรวจสอบว่า commit นั้น good หรือ bad โดยรันสคริปต์ทดสอบอัตโนมัติ
git bisect run <script_name>

ตัวอย่างผลลัพธ์ของ Git Bisect
$ git log
b1a534f is the first bad commit
commit b1a534f89l2c3d4e5f6g7h8i9j0k1l2m3n4o5p
Author: Jane Doe <[email protected]>
Date: Thu Mar 14 14:30:00 2024 -0500
Update data transformation logic
สิ้นสุดกระบวนการ bisect และกลับสู่ HEAD ปัจจุบัน
git bisect reset
กรณีใช้งาน
เคล็ดลับ
git bisect run <test-script>Git ขั้นสูง