Git 進階
Amanda Crawford-Adamo
Software and Data Engineer
用二分搜尋找出引入錯誤的 commit 的工具
Git Bisect 指令
git bisect
目的
啟動 git bisect 工作階段
git bisect start
將目前狀態標記為壞的狀態
git bisect bad
標記最後一個已知的好狀態
git bisect good <commit-hash>

將目前提交標記為壞提交
git bisect bad
將目前提交標記為好提交
git bisect good

透過執行自動化測試腳本,檢查該提交是好是壞。
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 進階